but i get a error
Error BCE0044: expecting :, found ‘if’
heres the script
u placed wrong semi colon…ur code should be look like this.
function update () {
if(Input.GetKey(KeyCode.LeftArrow))
{
rigidbody.AddForce(Vector3.left*5);
if(Input.GetKey(KeyCode.RightArrow))
rigidbody.AddForce(Vector3.right*5);
}
thanks for the reply but i got another error
Error BCE0044: expecting }, found ‘’.
sorry im still really new to scripting
nevermind i fixed it thanks
Sorry, but your code still has an obvious problem inside it. The code for going right won’t execute unless you’re already going left (maybe you want this , I don’t know). If not, try something like this:
function update () {
if(Input.GetKey(KeyCode.LeftArrow))
{
rigidbody.AddForce(Vector3.left*5);
}
if(Input.GetKey(KeyCode.RightArrow))
{
rigidbody.AddForce(Vector3.right*5);
}
}