yanmths
November 24, 2016, 4:59am
1
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));
}
Gizmoi
November 24, 2016, 8:02am
2
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
yanmths
November 25, 2016, 1:23am
3
Gizmoi:
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.
You were amazing. Thank you very much.