i got two rotating objects that hit each other so i want to instantiate sparks at colliding point. (oncollision) and (ontrigger)

@robertbu
i got this post …but being a newbie i am not able to understand…can some body give complete code…thanks…also how to do it with ontrigger and oncollision.

Do you want your objects to always rotate at the same speed, or do you want them to collide with each other?


Basically if you want collision events, you need rigidbodies. No more than one of the objects can be kinematic, and neither can be triggers.


If one or both objects should accurately simulate physics (bounce against each other), it’s easy. One or both of the objects should be non-kinematic, both should be non-trigger, and at least one should have an OnCollisionEnter function.


In that function, instantiate a spark prefab on the collision points, which you get from the OnCollisionEnter parameter. Or you can use a single particle system and call the Emit function on all contact points. You can also use OnCollisionStay if you want sparks to keep flashing if the objects stay together.


However if both objects are kinematic, they will pass right through each other, and you won’t get any collision event.

If one or both of the objects are triggers, you’ll get an OnTriggerEnter event, which doesn’t tell you the contact points.