- Home /
Question by
VincentRodriguez · Feb 13, 2012 at 09:55 AM ·
collisionraycastpointracing game
Collision point on surface?
Hi,
I'm creating racing game and I don't know how to instantiate sparks in collision point, can someone help?
Thanks a lot.
Comment
Best Answer
Answer by Grrillo · Feb 16, 2012 at 12:01 AM
Hi,
When you have a collison (assuming you are using OnCollisionEnter) then point of contact is stored in then Collision object. It's accesible by "collision.contacts".
void OnCollisionEnter(Collision collision) {
// 1st point of contact
ContactPoint contactPoint = collision.contacts[0];
// Create the prefab at the contact point of the collision
Instantiate(prefab, contactPoint.point, transform.rotation);
}
I can't test it right now to test this... let me know if it helped =D
Your answer
![](https://koobas.hobune.stream/wayback/20220613064032im_/https://answers.unity.com/themes/thub/images/avi.jpg)