All Questions


Anthony Base

Bug involving velocity not resetting right.

For whatever reason, I had to change a line in the hook state to make mine work properly. The main change was putting the velocity term in the dictionary as a string. I'm not sure why, though, as you didn't need to do that on your end.
  • B
    Anthony Base replied

    _state_machine.transition_to( "Move/Air", { velocity: velocity }) was changed to

    _state_machine.transition_to( "Move/Air", { "velocity": velocity })

    What happened with the first line of code was that the velocity was being, like, "popped back" to the velocity it previously had before I fired the hook? When I put the quotes in, however, it started assuming the velocity as was adjusted by the hook state.

  • B
    Anthony Base replied

    I wouldn't say this is a bug for the tutorial code, it just seemed to function weirdly on my end.

  • B
    Anthony Base replied

    For clarity, my Move/Air state's enter() function looks like this:

    func enter(msg: Dictionary = {}) -> void:

       var move: = get_parent()


       # Set custom horizontal acceleration,

       # only for this state.

       move.acceleration.x = acceleration_x

       if "velocity" in msg:

          move.velocity = msg.velocity

          # Because of the hook, we want

          # the max speed to be able to

          # be AT LEAST more than the

          # default max speed, while in

          # the air, to make it feel Rad.

          move.max_speed.x = max(

             abs( msg.velocity.x ),



       if "impulse" in msg:

          move.velocity.y = 0

          move.velocity.y = calculate_jump_velocity( msg.impulse ).y

  • B
    Anthony Base replied

    Figured it out, it was indeed my fault.

    I wrote down:

    _state_machine.transition_to( "Move/Air", { velocity: velocity })

    The video *clearly* writes:

    _state_machine.transition_to( "Move/Air", { velocity = velocity })

    There we go.