- Home /
Object movement with different time scale
Hi everyone,
Ricardo
Answer by ricardoluz19 · Jun 22, 2020 at 02:29 PM
Hi Everyone,
I have managed to found the solution if this can help anyone in the same situation.
Basically I knew that I had to relate the heightDelta with the the Time.DeltaTime somehow, but if I multiply it directly in the instruction above (in the position update), the car when in slow motion will just jump lower as the Time.DeltaTime is smaller with a smaller Time.TimeScale.
The solution was to use the Time.DeltaTime as I am calculating the heightDelta. To calculate the jump trajectory I am using a parabolic equation like:
h = -t^2 + (ti+tf)*t - ti*tf + h0 where (ti,h0) is the initial jump height and time instant.
Let's consider that the car is jumping from the current car position and we start to measure time from the instant we jump, so we can consider (ti,h0) = (0,0). The tf is the duration of the jump we want. With this we endup with: h = -t^2 + tf*t.
Refer to this page where I found similar information: https://answers.unity.com/questions/1113304/how-can-make-my-player-to-jump-like-parabola.html
From this point we can simply replace t by the current Time.DeltaTime to get the height value.
As the car position is being calculated by using the current position itself, I cannot use the height directly coming from the above equation because we will be always adding positive values which will make the car only go up but will not go down.
What we need to do is to calculate the heightDelta that will be result from recursively subtracting the previous from the current height: heightDelta = h(n) - h(n-1)
With this we can use different time scales and still mantain the same behaviour when jumping.
Your answer
![](https://koobas.hobune.stream/wayback/20220613001157im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Move object from point a to point b 1 Answer
(2D) Game runs faster when quality is set to low 1 Answer
Move a object to certain cordinates 2 Answers
2D- Move bullet in every direction 1 Answer