playMaker

Author Topic: Unity Animator Resets Time Scale [Solved]  (Read 2027 times)

Zenn

  • Playmaker Newbie
  • *
  • Posts: 2
Unity Animator Resets Time Scale [Solved]
« on: June 15, 2023, 02:07:14 AM »
So, long story short, I have explosive barrels that have a PlayMaker FSM on them to set the time scale to 0.25 when they blow up. However, when swapping weapons, I noticed it not only resets the time scale, but increases it. (Likely 4x which is the opposite of 0.25x). I did some testing by blowing up the barrel and spawning in different gameobjects directly after. Any item that either activates or spawns in with an animator on it resets the time scale to be much higher than I want. I have no idea why this happens or what the fix would be. I tried setting the animators to unscaled time update mode but that didn't work either. Has anyone experienced this that might know a solution?
« Last Edit: June 15, 2023, 03:35:42 PM by Zenn »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Unity Animator Resets Time Scale
« Reply #1 on: June 15, 2023, 05:23:58 AM »
Hi.
im do not know how you set it up, but i think that you need to setup a 'Manager' for this.

as you might have multiple objects changing the timescale.

so instead of that, have a object with 2 fsms.

on the 1st fsm have a global event and a variable for the timescale value (and optional a time duration).
and set a bool variable "isActive"

Set a bool test to check if isActive, if active do nothing.
if not active, use Set Fsm Float and set the time scale value (and optional time)
to the 2nd fsm.
Then send a event to start the timescale on the 2nd fsm.

then on the 2nd fsm set the timescale and a wait(probably best to turn on realtime)
with a global event as well (to send the event to)
when a timescale is set do a Set Fsm Bool and set the "isActive" on fsm 1 to true,
when the timer ends set timescale back to 1 and do again a Set Fsm Bool and set the "isActive" on fsm 1 to false


Zenn

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Unity Animator Resets Time Scale
« Reply #2 on: June 15, 2023, 03:34:49 PM »
Well, I feel a bit silly but I figured out my issue. I am using a system that reverses time as well. I didn't think it was the culprit but after looking at the code, I realized it was setting the time scale to 1 on Update(). Not quite sure what it had to do with animators or why time was speeding up but literally just commenting it out of the code and letting the new slomo manager that djaydino recommended control the time scale seems to have fixed it. Thank you!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Unity Animator Resets Time Scale [Solved]
« Reply #3 on: June 16, 2023, 07:39:22 AM »
Hi.
I am happy it worked.

You can even expand this with a "Priority" level.

I use this for camera shake in our game.



You just add an extra int (priority level) variable on fsm 1.
and add another int variable (current level)
When you set the value to the 2nd fsm, also set the int value to 'current level'

then after you test 'isActive' , if true you can compare the level.
if 'priority level' is higher than 'current level' you can re trigger the event.

on fsm 2 when timer ends use Set Fsm Int and set the 'current level' to 0