- Home /
unknown identifer explosion problem
when i type in this code:
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 ); }it says that the explosion is a unknown identifier
can anyone help make it not say that
this code is for a explosion to happen every time the gameobject hits something
Answer by aldonaletto · Dec 30, 2011 at 10:44 PM
Unity is right: you've not declared the explosion variable! You should declare it as a GameObject (to match instantiatedExplosion's type) and drag your explosion prefab to it at the Inspector:
var explosion: GameObject; // <- drag the explosion prefab here
function OnCollisionEnter( collision : Collision ) ...
Answer by Blahhh · Jan 02, 2012 at 03:24 PM
thanks but when i put that in it says
Assets/Setforward.js(5,28): Expressions in statement must only be executed for their side effects
what does this mean and how do i solve it
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Yield function goes slow sometimes/differently? 2 Answers
Gui placement help 1 Answer
How To Make GUI Buttons Load/Quit 1 Answer
what is the problem of this code ? 2 Answers