Accelerating Forward

I am trying to get my character to move forward without any form of input. I tried this script, but it doesn’t work:

var speed = 2.0;

function Update()
{

transform.postion += transform.foward * speed;

}

Please help me. Thanks

3 Answers

3

Your maths implies a constant velocity, not an acceleration. You might need to explain what “doesn’t work” means if you need more help.

It looks like you had a typo.

transform.foward
should be
transform.forward (it was missing an r)

Try if this works better for you.

var speed = 2.0;
function Update() {
    transform.postion += transform.forward * speed;
}

When you hit problems, always check the console log for any error messages. These are great places to find clues when you feel stuck.

var speed = 2.0;

function Update() {

   transform.Translate(Vector3.forward * Time.deltaTime * speed);

}