Godot Version
4.3
Question
Hi everyone!
I’m facing an issue with is_on_floor()
method in a CharacterBody2D
. I’m rotating the character to change the gravity. Right now, I’m changing the value of up_direction
property so I can change what is considered a floor. But when touching the floor the first time, the character remains in the floor, even with up_direction
pointing in other direction.
Even if I change the collision shape and keep the character in the air by rotating it, is_on_floor()
still results in true
.
Any idea of why this is happening? I was expecting the is_on_floor()
to result false
after rotating, since the character floor direction isn’t the regular anymore. The state machine would then change the state to fall.
extends State
class_name StarAvatarIdleState
@export var actor:GameCharacter
@export var move_component:MoveComponent
@export var gravity_component:GravityComponent
enum {
ROTATE,
FALL
}
func physics_process(delta:float) -> void:
if actor.is_on_floor():
move_component.velocity = Vector2.ZERO
return
else:
transitioned.emit(transition_states[FALL])
return
return