- Home /
BCE0043: Unexpected Token: Contact Error
I'm getting and error saying "BCE0043: Unexpected Token: Contact". Here is a picture of the Error:

This is the script the error is on:
 function  OnCollisionStay (collision : Collision) 
 contact : ContactPoint in collision.contacts;
 
     if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope)
         grounded = true;
The error is on the line:
 contact : ContactPoint in collision.contacts;
If you know what I'm doing wrong, Please leave a comment below! Thanks In Advance.
 
                 
                unity answers pic .11.jpg 
                (7.7 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Bunny83 · Aug 12, 2012 at 03:17 AM
It seems you extracted this line from a for-in loop statement. This doesn't work without the loop ;)
If you want to access just the first contact point do this:
 function  OnCollisionStay (collision : Collision)
 {
     var contact = collision.contacts[0]; // the first contact point
     if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope)
         grounded = true;
 }
If you want to check all contactpoints (since there could be more than one) use it in a for loop like this:
 function  OnCollisionStay (collision : Collision)
 {
     // This will iterate through all contact points
     for(var contact : ContactPoint in collision.contacts)
     {
         if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope)
             grounded = true;
     }
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                