#How can I get which face normal hit with raycast?

1 messages · Page 1 of 1 (latest)

lilac juniper
#

Assuming the collision shape is a simple cube, how can I detect which surface is hit using a raycast?

For example if the raycast hit the top face, it should give me Vector3(0, 1, 0) as result.

Is there any helper function for this?

Godot version 4.0

(ping me please)

granite lake
#

@lilac juniper closest I can think of is get_collision_normal(). Whatever specific face of your shape that corresponds to you'd have to figure out yourself.

#

In the case of a cube it should get you that vector you mentioned I think.

granite lake
#

Or if you are directly casting through intersect_ray or something, the resulting dictionary also contains the normal.