hit.point bug

Hi. Excuse my bad english.

I’m trying to create bullet holes, but hit.point returns the Y position set to 4.3, regardless of where I shoot. How can I solve?

I made a video about it, see:

RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit, wData.maxDistance, 1))
{                       
       if (hit.transform.tag == "BulletHole")
             Instantiate(Resources.Load("Prefabs/BulletHole"), hit.point + (hit.normal * 0.00100f),          Quaternion.FromToRotation(Vector3.up, hit.normal));
}

I would assume because transform.position is the position of your character at his feet. And similarly transform.forward is the forward vector of your character at his feet.
You want to fire from the centre of your camera, or possibly down the barrel of the gun, depending what you want to achieve.

1 Like

You were amazing. Thank you very much.