Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Keep a speed constant

Asked by
TomsGames 225 Moderation Voter
10 years ago

Right, in my game Traffic Racer I've decided to address the issue of speed. When driving, if I drive slowly at 30 mph at the first line of cars I am at about 100 'meters'. If I put full throttle down at 110 mph I get to like 60 'meters'. These are not accurate, but this is effectively what is happening. Why? How can I stop this?

This is the equation I am currently using:

            distance = distance + math.ceil(speed/600)

It is in no terms mathematical, but it adds a distance every wait() so it needs to be a fairly small value hence why it's 600.

Can anyone suggest a sum and wait() period that will keep it constant? So if I go at 30mph for 10 seconds I gain 300 'meters' and if it is 60mph I get 600 'meters'.

Thanks!

1
Lack of friction could be an issue if it's physics-based. 1waffle1 2908 — 10y
0
Surely there's some sort of equation. Anyway, why would I get a thumbs down for a hard question? It's perfectly valid.. TomsGames 225 — 10y

1 answer

Log in to vote
0
Answered by
MrNicNac 855 Moderation Voter
10 years ago

v = d/t

That's one of the simplest equation in physics. You're currently doing d = d + v, which is not valid anywhere.

v is 'velocity' or simply 'speed'

Velocity = Distance/Time

You can solve that for each variable in Multiple forms

Distance = Velocity * Time

Time = Distance/Velocity

Ad

Answer this question