- Home /
Question by
Shadow guardian · Mar 04, 2011 at 07:05 PM ·
instantiateoncollisionenterfirst-person-controller
Explosion on contact?
I am in an orginization called TSA(technolegy student assocoiation)I need to find a script that makes an explosion when it makes contact with the firt person controller?
Comment
What's with the title, "$$anonymous$$aking an object loop?" btw?
Best Answer
Answer by by0log1c · Mar 04, 2011 at 07:11 PM
You don't give much info, but here's a pseudo-code, in JS:
var theExplosion:GameObject;
function OnCollisionEnter(coll:Collision){ if(!coll.gameObject.GetComponent(CharacterController)){ return; } Instantiate(theExplosion,transform.position,Quaternion.identity); }
This is a pretty basic example but it should do what you need. Just drag the explosion prefab in the Inspector.