I was implementing the FPS tutorial’s “create explosion on hit” part to my project but my particle effects seems to be happening inside the object I am hitting rather than on the surface. I tried modifying the hit location a bit to see if the effect moves out of the object but it doesnt seem to work.
Here is my code:
var CreateSparks : Transform;
private var lifeTime : float = 0.05f;
function OnCollisionEnter(collision : Collision)
{
//Rotate the object so that the y-axis faces along the normal of the surface
var contact : ContactPoint = collision.contacts[0];
var rot : Quaternion = Quaternion.FromToRotation(Vector3.forward, contact.normal);
var pos : Vector3 = contact.point;
Instantiate(CreateSparks,pos,rot);
Destroy(this.gameObject,lifeTime);
}