Coordinates of bullet hit

Hi guys :slight_smile:

I am trying to create an FPS game, so I have a gun, bullets and so on.

My script for the bullets is:

var Bullet : Transform;
var Spawn : Transform;
var fireRate : float;

private var nextFire : float;
 
function Update () {
    if(Input.GetButtonDown("Fire1") && Time.time > nextFire)
    {
 	  	nextFire = Time.time + fireRate;
        
     	Shot();
    }
}
 
function Shot()
{
     var pel = Instantiate(Bullet, Spawn.position, Spawn.rotation);
     pel.rigidbody.AddForce(transform.forward * 7000);
     
}

So I have bullets which I shoot everywhere, bullets have set “use gravity”, so their distances are different. I want to display a little smog where you hit and ground parts blow up and so on. But I need coordinates of bullet impact, but I have no idea how :confused:

Can you help me guys? :slight_smile: sorry for my bad english

The bullet object needs a small script that calls OnCollisionEnter, and in that function, use Collision.contacts to get an array of ContactPoints. Use one of them (shouldn’t matter hich one with a small collider like the bullet would have) to get the ContactPoint.point (Vector3). Then, you just instantiate a particle system at this position, or even better, give each bullet a PS and make it start upon hitting something (Make the bullet stop and disable it’s collider and MeshRenderer; Use a CoRoutine to destroy the bullet after the particle system’s dust has dissipated).

yeah got it work :slight_smile: problem was in “is trigger” and with that, OnCollisionEnter doesnt work :slight_smile: so now works everything :slight_smile: now I need to find out, how to rotate hole in the ground and so on, because it looks very strange :smiley: