Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Keep a speed constant

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!

2 comments

1

Lack of friction could be an issue if it's physics-based.

0

Surely there's some sort of equation. Anyway, why would I get a thumbs down for a hard question? It's perfectly valid..

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.