- Home /
FPS Script Error OnCollisonEnter
I have run across this error with the FPS script using Unity 3, I have researched the functions and it seems to be alright but Im missing something. Could I get a fresh set of eyes and let me know what you think? Thanks!
var projectile : Rigidbody; var speed = 20;
function Update () { if( Input.GetButtonDown( "Fire1" ) ) { var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,transform.root.collider );
}
var explosion:GameObject; function OnCollisionEnter( collision : Collision ) { var contact : ContactPoint = collision.contacts[0]; var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal ); var instantiatedExplosion : GameObject = Instantiate(explosion, contact.point, rotation ); Destroy( gameObject ); } }
Here is the error:
Assets/Scripts/LazerCode.js(16,10): BCE0044: expecting (, found 'OnCollisionEnter'.
Answer by Mike 3 · Nov 18, 2010 at 04:49 PM
You're missing a } to end update - though it looks like the one at the bottom of the script is the one that should be up by update
Move the bottom } to just above var explosion and it should fix the error
Oh my goodness thank you so much $$anonymous$$ike! That did the trick.
Your answer
Follow this Question
Related Questions
ShopScript.Js(49,17): BCE0044 expecting :, found GUI. 1 Answer
EOF error message 2 Answers
sript gets error 2 Answers
HELP!! expecting :, found ';' problem 2 Answers
Assets/Shoot.js(7,90): BCE0044: expecting :, found ';'. whats wrong? 2 Answers