Comments and answers for "Object movement with different time scale"
http://answers.unity.com/questions/1743049/object-movement-with-different-time-scale.html
The latest comments and answers for the question "Object movement with different time scale"Answer by ricardoluz19
http://answers.unity.com/answers/1744591/view.html
Hi Everyone,
<br>
<br>
I have managed to found the solution if this can help anyone in the same situation.
<br>
<br>
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**.
<br>
<br>
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:
<br>
<br>
**<em>h = -t^2 + (ti+tf)*t - ti*tf + h0</em>** where (ti,h0) is the initial jump height and time instant.<br>
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: **<em>h = -t^2 + tf*t</em>**.
<br>
<br>
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
<br>
<br>
From this point we can simply replace **t** by the current **Time.DeltaTime** to get the height value.
<br>
<br>
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.<br>
What we need to do is to calculate the **heightDelta** that will be result from recursively subtracting the previous from the current **height**: **<em>heightDelta = h(n) - h(n-1)</em>**
<br>
<br>
With this we can use different time scales and still mantain the same behaviour when jumping.
<br>
<br>Mon, 22 Jun 2020 14:29:46 GMTricardoluz19