Floor Angle, Sliding and a state machine

GODOT 4.7.1

I have made a state machine that calculates the velocity of each of states inside of themselves then they emit that velocity back up to the physics process. None of them use move_and_slide() themselves.

I want to add a slide into the game which if I want to use get_floor_angle() requires me to use move_and_slide() otherwise I get the “get_floor_angle() not found in base self.”

So how do I get the state to pull that information without adding move_and_slide() to it?
Do I make a floor angle signal which the physics process emits back down to the slide state?

or

Do I just add a raycast to the bottom of the entity and manually programme it in to avoid messy signalling?

or

A much simpler thing I don’t know about?

The only tutorials I have found about programming a slide use a single node for their character controllers so they don’t run into this issue

get_floor_angle is a function that only exists in the CharacterBody2D or 3D class. It’s not based on whenever you use move_and_slide or not. Your instance needs to inherit CharacterBody2D or 3D for the function to be present.

Thanks. Each of the states are just nodes so I guess that explains why get_floor_angle() isn’t there. So if I run that function inside of the character 3D body how do I get that information down to the state?

That’s completely up to how your code is structured. I would assume your player has the state machine, so you can pass it as an argument in a lot of different ways, or your state machine can also have a reference to the player and do it that way. I cannot tell without knowing how your project is structured.

So sorry xD I guess abstractly talking about it won’t help. Inside the character 3D body are just these two lines.

func set_velocity_from_motion(vel:Vector3) -> void:
	velocity=vel

func _physics_process(_delta: float) -> void:
	move_and_slide()
#k I assume that get_floor_angle sits inside this function so it'd be the case of getting that vector from here

Each node kinda looks like this and extend the “Motion” class which contains constants, variables and all the formulas. This is the one for sliding so far (its just a modified sprint so far).

extends Motion

signal boost_end

func _enter() -> void:
	print(name)
	
func _state_input(_event: InputEvent) -> void:
	if _event.is_action_pressed("Movement Action"):
		finished.emit("Boost_Move_Action_Jump")
		
	if _event.is_action_released("CrouchnSlide"):
		finished.emit("Walking")
	
	if _event.is_action_released("Boost"):
		boost_end.emit()
		finished.emit("Walking")
	

func _update(_delta: float) -> void:
	_calculate_speed_multiplier(speed_stat)
	_set_direction()
	_calculate_velocity(_delta,ACCELERATION*multiplier*1.5, DRAG*multiplier,BASE_SPEED*multiplier*1.5)

#k I need the angle down here so that the angle of the terrain modifies the drag and acceleration


	if velocity.length() < SLIDE_MIN or stamina_remaining <= 0:
		boost_end.emit()
		finished.emit("Walking")	
		if direction == Vector3.ZERO:
			boost_end.emit()
			finished.emit("Idle")
	
	if not is_on_floor():
		finished.emit("Falling")

I’ve been mushing together tutorials but most just have a single page but I have this state machine xD