#Need help regarding raycasting

1 messages · Page 1 of 1 (latest)

dry peak
#

how can i make a script return the angle in which a raycast hits a wall

#

(the white part represents the raycast, bad model i know)

lean mason
# dry peak how can i make a script return the angle in which a raycast hits a wall

Just the angle right?

use the dot product formula = arccos((dot product of a and b)/(magnitude of a * magnitude of b))

or just arccos(dot product of unit vector a and unit vector b)

Im gonna be so honest Im not sure if roblox gives any utilities to do this for you this is more of a math standpoint

Also youd have to multiply the initial raycast vector by -1 if its going toward the wall and not from the wall

your vector b should be the hit normal from raycast and vector a the raycast direction vector or vice versa

lean mason