Search Unity

What does tileAnimationData.animationStartTime actually do?

Discussion in '2D' started by coolblue2000, Jun 14, 2018.

  1. coolblue2000

    coolblue2000

    Joined:
    May 7, 2015
    Posts:
    24
    I have tried setting tileAnimationData.animationStartTime to various figures (I am trying to get the map tiles to start their animations at different times in order to stop them being in sync) but it does not appear to do anything. I have set it to 100, 1000, 10000 but the animations still seem to start immediately. The documentation is pretty basic and I can't find much online.
     
    rakkarage likes this.
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Have you tried a normalized value between 0 and 1? Just something to try, I've never used that property.
     
  3. coolblue2000

    coolblue2000

    Joined:
    May 7, 2015
    Posts:
    24
    No. It seems like that would be counter intuitive as the documentation says "The start time of the animation. The animation will begin at this time offset." However I will give it a try just in case.
     
  4. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Yeah, I realize that but the Animator in Unity makes use of normalized time values, so I figured it'd be worth a try since you've covered the other bases. Definitely not what the docs imply.

    You may want to share your class/snippet of code where you set the tileAnimationData just to be sure there's not another issue being overlooked.
     
  5. coolblue2000

    coolblue2000

    Joined:
    May 7, 2015
    Posts:
    24
    Code (CSharp):
    1. public override bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData)
    2.      {
    3.          if (_animatedSprites.Length > 0)
    4.          {
    5.              tileAnimationData.animatedSprites = _animatedSprites;
    6.              tileAnimationData.animationSpeed = m_MinSpeed;
    7.              tileAnimationData.animationStartTime = Random.Range(0f, 10000f);
    8.              return true;
    9.          }
    10.          return false;
    11.      }
     
  6. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    i am having similar issue
    animationStartTime is not working consistantly? or i am crazy or ghosts are F***ing with my code... or more likely i guess i just got a simple bug but idk weird

    https://github.com/rakkarage/TestAnimatedTile

    i just added randomStartTime bool to animatedTile so that i can sync some animations and randomize others

    but i cannot get the torches to randomize
    i got the banner animation to randomize but not the torch? so it must have something to do with the time or the number of animations in the animations because that is the only difference!?

    it works in editor but not in run!?

    i guess i will attempt the 0-1 fix
    EDIT: ya it is 0 to 1 i guess duh :)

    test.gif
     
    Last edited: Oct 7, 2018