Files
fps_project_1/scripts/HelperFuncs.gd
2024-12-12 15:08:44 -06:00

23 lines
956 B
GDScript

extends Node
## ANGLES
# Check if a colliding body is aligned within a given angle of the object
# max_angle_diff --- note: set to 1 if angle won't be counted
# currently only works when objects are scaled (1,1,1)
func angle_velocity_aligned(source:Node,source_angle:Vector3,body:Node,max_angle_diff:Vector3):
var obj_direction = source.basis * source_angle
print("SOURCE BASIS ",source.basis)
var player_direction = body.velocity.normalized()
var diff = abs(abs(obj_direction) - abs(player_direction))
print("------------------------------------------------------------")
print("OBJ DIRECTION: ",obj_direction)
print("PLAYER DIRECTION: ", player_direction)
print("MAX ANGLE DIFF ",max_angle_diff)
print("DIFFERENCE: ", diff)
print("------------------------------------------------------------")
if diff.x <= max_angle_diff.x and diff.y <= max_angle_diff.y and diff.z <= max_angle_diff.z:
return true
else:
return false