I’m working on a project where the player has the ability to slow down (and maybe faster) time.
I’m achieving that modifying the Time.timeScale value and everything works fine apart from some physics stuff…
Let’s make a real example of what I would love to obtain… something like Max Payne.
when in “bullet mode” (time slowed down) if you shoot with your weapon you can actually see the bullets but as soon as you get out from the “bullet time” (normal time speed) all the bullets continue their simulation at normal speed
In Unity if I use AddForce to a rigid body while in “slow down mode” seems like the force itself is scaled down so when I go back to a “normal time speed” the “scaled force” has already been applied and the “object keep moving in slow down”, the effect is completely different of when I apply the same Force Vector with timeScale==1.
I tried without scaling the Time.fixedDeltaTime but it doesn’t looks ok…
this is my first approach with the unity physics so I hope it’s just a noob question…
Can you post the code you are using to add forces to the rigidbodies? Generally, you should multiply Time.fixedDeltaTime by the same value you are using for Time.timeScale.
when my event occour (let’s say mouse click, m_direction is a normalized vector)
I read that unlike the Constant Force component the AddForce function should be called just once and not every frame so I’m calling it only when the event is fired, hope it’s correct…
and yes I’m multiplying the fixedDeltaTime too
Time.timeScale = timeScale;
if (bScalePhysics)
Time.fixedDeltaTime = startPhyTime * Time.timeScale;
bScalePhysics is just a boolean to check the difference when I apply or not the scale to the physics, startPhyTime is storing the fixedDeltaTime starting value (on Start())
If I’m not mistaken, if you’re only applying a single explosive force (as opposed to a constant force over time), you shouldn’t be scaling that with the TimeScale.
well… I tried not to scale the fixedDeltaTime but the effect is just weird…
looks like is not scaling the physics simulation but the rendering(/update?) is “scaled” (by the normal Time.timeScale) so my object “teleport” across the scene
my real scenario is a football game where the player has the chance to slow down time and my problem is on the ball when he tries to strike (i’ve got something like a powerbar growing up on mouse down and shoot/add the force on mouse release).
what’s the best way to achieve this kind of simulation? constant force?
in that case how do I apply a constant force? simply calling AddForce every frame or there’s any other best way to do that?
yes I’ve seen it but the problem is that is not what i need in this case…
when the player hit the ball he’ll choose the /, in this case the ball have to behave in a realistic way with that pair of values and I think I have to apply a normal AddForce on the “shoot instant” to achieve that…
that brings me back on my original question “why it doesn’t work?”