x


expressions in statements must only be executed for their side effects

here is my unfinished race car script

var movespeed = 0;
var turn = 0; // plus for right, minus for left
var maxspeed = 16;
var minspeed = -8;


function Update () {
transform.Translate(Vector3.left * Time.deltaTime * movespeed);
transform.Rotate(Vector3.up * Time.deltaTime * turn);


if (Input.GetKey("a")){
turn - 3;
 }

if(Input.GetKey("d")){
turn + 3;
}

  if (Input.GetKey("w")){
movespeed + 0.5;
  }

   if (Input.GetKey("s")){
  movespeed - 1;
}
if (movespeed >= maxspeed){
movespeed = maxspeed;
}

if (movespeed <= minspeed){
movespeed = minspeed;
}
}

im getting the error "expressions in statements must only be executed for their side effects" at

turn - 3;
turn + 3;
movespeed + 0.5;
movespeed + 1;

does anyone know what the problem is?

more ▼

asked Nov 18 '11 at 04:01 AM

sam32x gravatar image

sam32x
178 40 56 62

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You're doing it wrong - the variable increment must be done this way:

 turn -= 3;
 turn += 3;
 movespeed += 0.5;
 movespeed += 1;
more ▼

answered Nov 18 '11 at 04:09 AM

aldonaletto gravatar image

aldonaletto
41.6k 16 42 197

oh oops thanks

Nov 18 '11 at 04:48 AM sam32x
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3345
x539
x57

asked: Nov 18 '11 at 04:01 AM

Seen: 1061 times

Last Updated: Nov 18 '11 at 04:48 AM