user13650168
user13650168

Reputation:

Unity get XYZ of raycast

I am not sure how to get the coordinates of a raycast. I have looked through the documentation and from what I gathered there is no methods that pull out the specific coordinates from a raycast. How do I go about getting the position of a raycast so other objects can move with it?

Upvotes: 0

Views: 1125

Answers (1)

tlz13
tlz13

Reputation: 136

Try this:

RaycastHit hit;
if (Physics.Raycast(ray, hit)){
    Debug.Log(hit.point)
}

The hit.point is the location where the ray hit (Vector3).

Upvotes: 1

Related Questions