meat_madness_redux/godot/player/CloseToFloor.gd

18 lines
377 B
GDScript3
Raw Permalink Normal View History

2022-11-27 19:55:11 -07:00
extends RayCast
var is_on_floor = false
var floor_distance = 0.0
2022-12-11 17:02:57 -07:00
export var min_floor_distance = 0.5
2022-11-27 19:55:11 -07:00
func _process(_delta):
force_raycast_update();
if is_colliding():
var point = get_collision_point();
floor_distance = to_local(point).length();
2022-12-11 17:02:57 -07:00
if floor_distance < min_floor_distance:
is_on_floor = true
else:
is_on_floor = false
2022-11-27 19:55:11 -07:00
else:
2022-12-11 17:02:57 -07:00
is_on_floor = false