x


Is this correct to modify real time unit to match with timescale?

I have many simple physics calculation in my script to predict future position, speed or time of the object. The distance shouldn't have any effect from the scale though. For example

distance = speed*time + 1/2*accelerate*time^2
finalSpeed = startSpeed + accelerate*time
finalSpeed^2 = startSpeed^2 + 2*accelerate*distance

If I change the timescale in Unity, how should I change the scale of variables in above equations? The above equations are all real time unit. Is it correct that I have to divide real time unit with timescale? Like this

speed is meter/second so scaleSpeed = speed*timescale
time is second so scaleTime = time/timescale
accelerate is meter/second^2 so scaleAccelrate = accelerate*timescale*timescale

My other question is when I get the value from rigidbody.velocity Is its unit (meter/second) already scaled with timescale or not? And when I use Addforce ForceMode.VelocityChange to change object velocity. If I want to apply velocity = 10 meter/second in real time to the object. Can I use 10 directly or do I need to scale it with timescale before apply it to Addforce?

more ▼

asked Sep 17 '10 at 02:06 AM

jjobby gravatar image

jjobby
417 27 34 46

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Is it correct that I have to divide real time unit with timescale?

Yes, when you are predicting what the physics will do over time. You can test this by plugging in sample values like 0.5, 1, and 2.

However, in Unity it depends what you do with these numbers. If something is going to happen at Unity Time=3 for example, it will still happen at Time=3 at half speed. It's just that Time=3 won't be seen by you until 6 seconds have elapsed. (Note: Time.realtimeSinceStartup tracks real-world time.)

rigidbody.velocity Is its unit (meter/second) already scaled with timescale or not?

The velocity value should always look the same regardless of timeScale. Think of it this way: the Unity simulation of the physics doesn't change when timeScale changes; you are just changing how quickly the results are played back.

Can I use 10 directly or do I need to scale it with timescale before apply it to Addforce?

Just apply the 10m/s as you were planning to do. The physics inputs don't change; you are just experiencing the final playback slower or quicker.

more ▼

answered Sep 17 '10 at 11:17 AM

Bampf gravatar image

Bampf
5k 8 19 49

(comments are locked)
10|3000 characters needed characters left

why we should use second unit in our graph?? not minute,hour or etc...especially for realtime

more ▼

answered Jan 25 '11 at 06:49 PM

Arnie john gravatar image

Arnie john
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1880
x212
x85

asked: Sep 17 '10 at 02:06 AM

Seen: 938 times

Last Updated: Sep 17 '10 at 04:01 AM