- Home /
 
               Question by 
               mckadan.fields · Jul 31, 2014 at 05:21 AM · 
                 
              
 
              How can i fix this error?
I am making a game in unity and cant get rid of this error :
Assets/Scripts/BallControl.js(14,22): BCE0034: Expressions in statements must only be executed for their side-effects.
Does anyone know how to get rid of it?
Here is my script:
 #pragma strict
 
 var rotationSpeed = 100;
 var jumpHeight = 8;
 
 var Hit01 : AudioClip;
 var Hit02 : AudioClip;
 var Hit03 : AudioClip;
 
 var distToGround : float;
 
 function Start () {
     // Getting the distance from the center to the ground.
     distToGround + collider.bounds.extents.y;
 }
 
 function Update () 
 {
     //Handle ball rotation.
     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
     rotation *= Time.deltaTime;
     rigidbody.AddRelativeTorque (Vector3.back * rotation);
     
     if (Input.GetKeyDown(KeyCode.W) && IsGrounded ())
     {
         rigidbody.velocity.y = jumpHeight;
     }
 }
 
 function IsGrounded () : boolean { //Check if we are on the ground. Return true if we are else return null.
     return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1);
 }
 
 function OnCollisionEnter () {
     var theHit = Random.Range(0, 3);
     if (theHit == 0)
     {
     audio.clip = Hit01;
     }
     else if (theHit == 1)
     {
     audio.clip = Hit02;
     }
     else {
         audio.clip = Hit03;
     }
     audio.pitch = Random.Range (0.9,1.1);
     audio.Play();
 }
               Comment
              
 
               
              Answer by robertbu · Jul 31, 2014 at 05:24 AM
On line 15, you are using a '+' sign where I believe you should be using an '=' sign. The line should be:
 distToGround = collider.bounds.extents.y;
Answer by Arcadewiz · Jul 31, 2014 at 05:25 AM
Are you trying to do :
distToGround += collider.bounds.extents.y;
instead of :
distToGround + collider.bounds.extents.y;
Your answer
 
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity networking,Cant see each other move 2 Answers
Help! How can I get my power up script to work? 1 Answer
Toggle map/Camera [JS] 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                