Godot Version
4.4
In my code, I want to check the rotation of the player, which I am doing via the model node for this project, and use that to determine whether the player model would be in normal footing or goofy footing (this being a skateboard game).
After some testing, it seems that the problem is that the code somehow does not pass the if-elif statements and do the logic I ask it to.
So I am not sure where it is and I don’t feel rested enough to discern it today. I would like some help identifying the potential problem.
The relevant code is below:
extends CharacterBody3D
signal change_footing(footing: Footing.footing)
var in_air = false
var last_grounded_angle: float
@onready var model = $Model
func _process(delta: float) -> void:
if is_on_floor() and in_air:
check_footing()
elif !is_on_floor():
if !in_air:
in_air = true
last_grounded_angle = model.rotation_degrees.y
func check_footing() -> void:
in_air = false
var air_rotation = int(abs(last_grounded_angle - model.rotation_degrees.y))
if air_rotation < 160 and air_rotation > 200:
target_footing = GOOFY_FOOTING_ROTATION
change_footing.emit(Footing.footing.Goofy)
elif air_rotation < 20 and air_rotation > 340:
target_footing = NORMAL_FOOTING_ROTATION
change_footing.emit(Footing.footing.Normal)