1

I tried this in Unity with C# but I keep getting compiling error messages

void update ()
{ 
    if(Input.GetKeyDown(KeyCode.LeftArrow))
    { 
        transform.Translate(-1,0,0);
    }
}

where's the error? any alternative to perform simple movements?

1
  • 3
    "where's the error?" is a good question since we have no idea what your error is. How about including those compiler errors? Commented Oct 28, 2013 at 19:24

2 Answers 2

4

Your "update" method needs to be capitalized for Unity to recognize it. Your script will not hook in unless Unity can see that the method name matches one of the ones it's looking for. As for an alternative for simple movements, watch some tutorials on how CharacterControllers work. They have two functions that are pretty easy to use, which are Move, and SimpleMove.

Sign up to request clarification or add additional context in comments.

Comments

1

"update" cahnge to Update

and

void update () { 

if(Input.GetKeyDown(KeyCode.LeftArrow)){ 

//(BAd usage)transform.Translate(-1,0,0);
transform.Translate(new Vector3(-1,0,0));
}
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.