Hi everyone. I’m nearly done with my first large practice project in Godot, a simple platformer, but I’ve hit a snag at the very end - literally, the end cutscene. I want to have my player character frozen while the cutscene plays.
I settled on creating a ‘Freeze’ state in my Finite State Machine system, that stops the player’s input entirely. So far, so good, but now I’m not actually sure how to call this state…
I have a very simple ‘Cutscene triggered’ Area2D that I want the player to enter to trigger the ‘Freeze’ state:
extends Area2D
func _on_body_entered(body: Node2D) -> void:
if body is Player:
$"../AnimationPlayer".play("FadeIn")
So basically my question is - how do I use a signal to force the player into a specific state?
Your errors describe a very different line of code, like you wrote Player.freeze() instead of body.freeze(). However I highly doubt this function does change states, you may even get a warning along the lines of “Statement has no effect”; but I do not know how you set up your state machine.
And you were also right that I mistyped the body.freeze() function. The print statement works, at least, so I can call the function. Now I just need to force it into what state I want.
func _on_body_entered(body: Node2D) -> void:
if body is Player:
body.freeze()
body.set_physics_process(false)
body.set_process_input(false)
body.set_process_unhandled_input(false)
$"../AnimationPlayer".play("FadeIn")
Its not exactly what I wanted with the call to a new state but I’ll settle for this for now, thanks to your help. Thank you!