Author Topic: Tweening at the start of a level  (Read 5855 times)

yeahus

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 10
    • View Profile
Tweening at the start of a level
« on: August 13, 2014, 04:06:15 AM »
I have some menus / items set to tween in at the start of a level (e.g. on the main menu the logo scales up then bounces). Sometimes this works fine, but often the tween will have finished before the scene has 'started' (for want of a better word).

I've tried starting a coroutine that waits for a couple of frames before enabling the tween, but I still see the behaviour sometimes. Is there an accepted way of dealing with this?

Thanks!

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Tweening at the start of a level
« Reply #1 on: August 13, 2014, 05:03:39 AM »
You could set a flag in your Coroutine like:


  1.  
  2. bool allowTweening = false;
  3.  
  4. IEnumerator WaitSomeFrames()
  5. {
  6.  yield return new WaitForSeconds(3.0f);
  7.  
  8. allowTweening = true;
  9. }
  10.  
  11.  
  12.  
  13. void TweenMethod()
  14. {
  15.    if(allowTweening)
  16. {
  17.  // do the tween
  18. }
  19. }

yeahus

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Tweening at the start of a level
« Reply #2 on: August 13, 2014, 05:09:10 AM »
Cheers for the reply but that'll just do the same thing - whether I set a flag there or enable the tween there makes no difference as far as I can tell?

I've actually got them working now anyway (as is normally the case in my book, as soon as I ask I figure it out!) - all I had to do was disable 'ignore timescale'. I presume between scenes Time.timescale is set to 0 (or something close) and is reset to 1 on start of the next scene. This works fine for the scenes I'm dealing with since they run at a normal timescale.

I'd be interested to hear if this is actually the case though!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweening at the start of a level
« Reply #3 on: August 13, 2014, 08:02:02 AM »
Yeah all UI tweens should be ignoring time scale anyway. It doesn't make much sense for UI to be frozen like the rest of the game.

yeahus

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Tweening at the start of a level
« Reply #4 on: August 13, 2014, 08:06:12 AM »
True, and most of my tweens do ignore time scale. However for these tweens that happen right at the beginning of a scene to work correctly I had to disable 'ignore scale' - i.e. don't ignore scale...