- Home /
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?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by aldonaletto · Nov 18, 2011 at 04:09 AM
You're doing it wrong - the variable increment must be done this way:
  turn -= 3;
  turn += 3;
  movespeed += 0.5;
  movespeed += 1;
Your answer
 
 
             Follow this Question
Related Questions
object rotating around parent 1 Answer
how to make an object "the target" when you click on it 3 Answers
function error 1 Answer
manabar doesnt work 1 Answer
C# Unity 3D Lock Rotation but allow Rotation of Parent Object 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                