All Questions

Community

B
Anthony Base
posted to: The Spawn State

My Solution

I simply created a spawn state for the hook. The hook's spawn state awaits a newly created signal that is owned by the Hook node named "hook_equipped," so that any entity that equips the hook can simply emit its signal when ready (such as at the end of a spawn animation). So basically in the player's spawn state, I've removed all the hook related code, and added to the end of the spawn state "if we have a hook, emit its equipped signal."
  • Nathan Lovato replied
    Thanks for sharing :)
  • Daniel Queiroz Porto replied

    I did it at the set_is_active of the hook:

    func set_is_active(value: bool) -> void:
        is_active = value
        visible = value
        hook_state_machine.set_process_unhandled_input(value)
        hook_state_machine.set_physics_process(value)
    

    Since I'm using it to set the visibility, I removed that line from the player Spawn state, and I set the hook_state_machine unhandled_input and physics_process on and off accordingly.