I'm trying to simulate a time-slowing effect in Unity, which is supposed to slow down things like the physics engine, animator speeds etc.
However, I also need certain GameObjects to be "immune" to this effect, so, as far as I understand, merely changing the value of Time.timeScale
won't work.
The solution I've arrived at is to multiply certain values of non-immune rigidbodies by a factor (for example 0.1), and then divide by this factor when the slowdown effect ends to effectively reset them.
I assumed doing this to the velocity
and gravityScale
of all non-immune rigidbodies, as well as the forces being applied to them, would be sufficient, but this does not seem to produce the desired effect.
As an example, jumping while time is slowed down produces a jump of 1/10th the height, that takes the same amount of time to complete (ie. reach the ground after jumping) when compared to jumping normally, when the desired effect is a jump of the same height, that takes 10 times longer to complete (assuming a slowdown factor of 0.1).
Any ideas on what other values must be changed in order to produce this effect? Or am I overthinking this and there is a simpler way to do it?
I'll gladly provide clarification/additional info if necessary. Thanks in advance.
velocity
andgravityScale
, where the factor of gravityScale is the square of the factor of velocity. like0.1
and0.01
. \$\endgroup\$