get_collision_normal() of raycast

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By shotaku

what does $RayCast.get_collision_normal() function mean guys?
And what does this command mean?
var basis = get_global_transform().basis
when i move the mouse with print(basis.x) or print(basis.z), it returns a vector variable, what does this vector value mean

:bust_in_silhouette: Reply From: Ertain

The normal vector is at a right angle to the collision. Described here in the article on Vector Math:

Normal vectors are unit vectors aligned perpendicularly to a surface, defining its direction.

A Basis is a matrix (3 Vector3 objects) which describe how a 3D object is scaled and rotated local to the 3D object. The global_transform part calculates it with respect to the scene as a whole.

can you give me a concrete example of get_collision_nomal() function

shotaku | 2022-02-22 06:38

Do you mean a code example, or an example of it in action, e.g. a picture or a diagram?

Ertain | 2022-02-22 09:20

i read some documents and i understand the return value of get_collision_normal() function is a normal vector with collision point , its true?

shotaku | 2022-02-23 07:28

More or less. get_collision_point() returns the point in space where the RayCast intersected the object. get_collision_normal() gives a vector that’s at a right angle to the object’s shape at the collision point.

Ertain | 2022-02-24 01:34