Please explain the mechanics of "self-knockback"

I am making a game where, when the player is hit by an enemy’s attack, they jump in the opposite direction while facing the attacking enemy.

Previously, I set attributes based on the direction of the enemy’s attack and used those attributes to determine the direction of the damage animation.

However, this method required preparing separate left and right states for both the attacker and the damage receiver, which tended to bloat the script. Due to the specifications of Action Game Maker, increasing the number of scripts and links degrades performance.

I considered that using the “Knockback” feature added in version 2.0 might simplify the script, but I couldn’t configure it correctly.

If I select “Left/Right” for the Knockback direction, the character moves left and right, but even with the “Perform Jump Action” checkbox enabled in the Action settings, no jump occurs.

I tried transitioning to another state with the “Perform Jump Action” checkbox enabled 0.1 seconds later, but the jump still did not occur.

The first attached image shows the state with Knockback applied, and the second image shows the node that triggers the jump.

I also tried selecting “Launch” for the Knockback direction, but no matter how I configured it, the movement direction and the sprite’s facing direction always remained the same.

Here are the configurations I tried:

Configuration

  • Launch: 45°
  • Opposite Direction: On
  • Face Opposite to Movement Direction: On
    Result: Faces the opposite direction of the enemy and moves in the opposite direction

Configuration

  • Launch: 45°
  • Opposite Direction: On
  • Face Opposite to Movement Direction: Off
    Result: Faces the enemy and moves toward the enemy

Configuration

  • Launch: 45°
  • Opposite Direction: Off
  • Face Opposite to Movement Direction: On
    Result: Faces the opposite direction of the enemy and moves in the opposite direction

Configuration

  • Launch: 45°
  • Opposite Direction: Off
  • Face Opposite to Movement Direction: Off
    Result: Faces the opposite direction of the enemy and moves in the opposite direction

Configuration

  • Launch: -45°
  • Opposite Direction: On
  • Face Opposite to Movement Direction: On
    Result: Faces the enemy and moves toward the enemy

Configuration

  • Launch: -45°
  • Opposite Direction: On
  • Face Opposite to Movement Direction: Off
    Result: Faces the enemy and moves toward the enemy

Configuration

  • Launch: -45°
  • Opposite Direction: Off
  • Face Opposite to Movement Direction: On
    Result: Faces the opposite direction of the enemy and moves in the opposite direction

Configuration

  • Launch: -45°
  • Opposite Direction: Off
  • Face Opposite to Movement Direction: Off
    Result: Faces the opposite direction of the enemy and moves in the opposite direction

Is it possible to configure “Knockback” so that the character flies backward while facing the attacking enemy?

In the practical examples in the tutorial, the direction was set to “Launch” with distance and time specified, but there is no distance setting for “Launch” (only for Left/Right), so that configuration is not possible. The only options available for Launch are Initial Velocity and Velocity Application Method.

I think the facing part might be the state itself rather than the knockback action. In your first screenshot the state’s Display Direction (表示方向) under Animation to Assign is set to Movement Direction, and I’m wondering if that’s re-applying the facing every frame and overriding whatever the knockback’s “display direction opposite to movement” option is trying to do. That could explain why all eight combinations only ever gave you two results.

What if you tried changing the state’s Display Direction to Use Face Direction Settings or Move Key, then turning on the knockback’s “display direction opposite to movement” option? I think that should leave the knockback in charge of the facing so you end up looking at the enemy while flying away.

For the jump, I think maybe the Launch (打ち上げ) mode already does what you want. It gives an initial speed at an angle, so 45 degrees at 400 should arc up and away on its own without Perform Jump checked. I’d also try turning off Ignore Gravity in that state, since the arc needs gravity to come back down. With Left/Right the knockback is a forced move, so I’m wondering if that’s what’s swallowing the jump.

Thank you.

After trying various options, I found that this configuration most closely matched my usual behavior.

  • Face direction settings

    • Use face direction settings: Yes
    • Change orientation settings: No
    • Display direction: Face direction settings
  • “Knockback self” settings

    • Knockback direction: Left/Right
    • Move in opposite direction: Off
    • Move in direction opposite to display: On

    With this setting, I get knocked back in the opposite direction while facing the enemy. The only issue is that I don’t jump.

    However, if I set the knockback direction to “Launch,” I fly backward in the same orientation regardless of the enemy’s position.

    I suspect that when using the “Launch” setting, the hitbox coordinates are not being properly acquired.

    Additionally, even with the “Left/Right” setting, if I set the movement time for jumping to 0.1 seconds and switch to another jumping state after 0.2 seconds, I still don’t jump. It’s also unclear when the forced knockback movement ends.

I have reviewed the specifications regarding this issue.

First, regarding knockback and jumping: horizontal knockback (left/right) uses the exact same processing as “move object.”
Since this involves forcibly moving the object to its destination, jumping is ignored during the forced movement but functions normally once the movement is complete.
Therefore, I initially thought the following report might be a bug…

Also, when setting the “left/right” jump movement time to 0.1 seconds and switching to another jump state 0.2 seconds later, it does not jump.

However, I was unable to reproduce this on my end. The patterns I tested and the results are listed below.

Jump Results (Left/Right Direction, 64px)

Setting Time of Jump Attempt Result
Arrival Time 0.1 sec Simultaneous with knockback Does not jump
Arrival Time 0.1 sec 0.2 seconds later Jumps approx. 123px (normal jump)
Arrival Time 0.5 sec 0.2 seconds later Does not jump (no jump occurs even after movement ends)
Object Speed 100%, 64px 0.2 seconds later Does not jump (movement took approx. 0.35 seconds)

It seems that the jump state is being entered before the forced movement is complete for some reason. Was the arrival time correctly set to 0.1 seconds? If it was set correctly, please provide screenshots of the knockback state’s actions and the transition conditions to the jump state.

Regarding the second point:

When setting the knockback direction to “launch upwards,” the character flies backward in the same direction regardless of the enemy’s position.

I was also unable to reproduce this. In the “launch upwards” case, the character might face down-left or down-right. I wonder if you perhaps haven’t set animations for diagonal directions? What do you think?

The first image shows the “Self Knockback” state, the second image shows the suspected link condition, the third image shows the intended jump state that follows, and the fourth image shows the subsequent link, which I have disabled for clarity. I ensured it always stops in the jump state.

The result is that it faces the enemy and moves in the opposite direction of the enemy, but it does not jump.

If you touch the enemy while holding the key on the enemy’s side, it will always face right and jump left, regardless of the enemy’s or your own position.

I tried setting the movement time to 0.2 and the link transition time to 0.4, but the result was the same.

When I changed the jump state image from “Maintain Pre-transition Animation” to specify a different animation:

It briefly faces the enemy, but then immediately faces right and jumps left, regardless of the enemy’s or your own position.

Regarding the “Launch” mechanic, I was unaware of the directional animation settings, so I believe it functioned correctly after I configured them.

For now, since the “Left/Right” specifications are unclear and I am unsure, I will avoid using “Self Knockback” as much as possible and only use “Launch” when absolutely necessary."}

It appears to be configured correctly.
I thought the “Move in Display Direction” setting, which is set to State 007, might be affecting it.

Regarding this, “Jump” will function as it did before,
but the newly added “Forced Movement (Object Speed)” and “Forced Movement by Arrival Time” settings will prevent “Jump” from working, as they use the same forced movement method as knockback.

Thank you. The “Move to Display Direction” setting remains unchanged.

Furthermore, even if “Move to Display Direction” is not executed, a character that has been attacked will briefly face the enemy and then invariably turn to the right.

Interestingly, when using the test play feature to pause just before taking damage and advancing frame by frame, the character facing the enemy would not subsequently turn to the right.

This behavior only occurs when using the pause function. If damage is taken and then frame-by-frame advancement is used without pausing, the character will again invariably turn to the right.

1 Like

Based on the information provided, we identified the likely cause.

The knockback action was failing to update the FaceDirectionSettings values, which prevented the character from orienting correctly when using FaceDirectionSettings.

We have released a fix for this issue. Please feel free to verify it.