- Home /
Question by
ObviouslyInsane · Aug 12, 2012 at 06:41 AM ·
collisionparticle
Emitting Particles on Collision
Hello all, I know this question has been asked and answered many times. I've looked through many of them and the documentation and I still cannot solve my problem. So basically I have a bullet object and when it collides with another object, I want it to emit a particle on the position of the object the bullet hit. Here's my current code:
var hitParticles : ParticleEmitter;
function OnCollisionEnter (collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
if(collision.collider.tag == "HitObject") {
Instantiate(hitParticles, contact.point, rotation);
}
I know the objects are colliding correctly because the print statement tells me it is, but the particle is not emitting at all. I have this script attached to my bullet object. Can someone give me an idea what I might be doing wrong? Thank you!
EDIT: Of course five minutes after I ask I figure it out. I updated the code in case anyone else is having this problem.
Comment