- Home /
Duplicate Question
Acceleration and deceleration systems
At the moment I am just messing aroundwith a box in Unity and practising my Javascript on it as I learn it . I only started a couple days ago so sofar I have only made it move around with cursor keys. But now I want to add an acceleration system to the box. Now I've seen other acceleration scripts I know it's not easy! But I think (emphasis on the word think) I have an easy solution. It may not be the mlst advanced accelerators, but it should work..
var speed = 0.3
if(GetKeyDown(KeyCode.UpArrow))
{
transform.Translate (speed += 2.0 * Time.deltaTime
}
So hopefully this script will increase the speed of the box per second, thus creating the illusion of acceleration? I'm currently away from my computer (I'm typing this from my iPod if you're wondering) so does anyone know if this will work? And does anyone know any others?
yes, basically that's correct arithmetic
I very much encourage you to next learn about **rigidbody**s - it's actually much easier
10000s of questions on here about acceleration and rigidbody and physics generally
unityGE$$anonymous$$S.com for a great many excellent articles on it