Addon StateCharts

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

Hello. my question concerns the addition of state charts. How can you immediately switch from a process state to another state without using send event? that is, immediately give the command to switch between states.

Here’s an example, my character is in an idle state, and if the floor collapses, I want him to go into a falling state. but I repeat - without using event sending. format “if something happened: then switch the state”

func _on_idle_state_physics_processing(delta):
	if not is_on_floor():
		# ?????????
		velocity.y += grv * delta

By send event, do you mean signal? It’s definitely the recommended way to do something like this.
If you want to do it manually, underneath your collapsing floor you could have a area2d/3d and check every frame if the player position is inside the area. When the check comes back true, you can trigger your state switch.

If you’re using a animationtree, you could also make it so any time your player is falling downwards, you play the falling state. I recommend watching this video if that’s what you want to do.