About this manual
This manual explains the visual script action “Knockback Self” (KnockbackSelf). It throws the object itself back using the direction of the last attack it received as the reference. It lets you build damage reactions such as “get knocked to the opposite side when an enemy hits you” or “get launched up and away at an angle” entirely in the visual script of the object that took the hit.
How knockback works in ACTION GAME MAKER
There are two ways to build a knockback.
| Approach | Where you set it |
|---|---|
| Throw from the attacker’s side | The settings and actions of whoever made the attack |
| Fly from the receiver’s side (this action) | The visual script of the object that took damage |
Building it on the receiver’s side means the reaction is the same whatever hit you. However many sources of attack you add — enemy attacks, bullets, spikes, lava — one action in the damage state covers all of them. Being able to decide the distance and speed of the knockback as “a property of the character who gets hurt” is an advantage too.
This action works as a forced move. It is the same mechanism as “Move Object” with a direction and distance, except that the direction is decided automatically from the damage information.
Using it
- Prepare the state you enter when damaged (a “hurt” state, say).
- Put “Knockback Self” into that state from “Add Other Action”.
- Set the reference point, how the direction is calculated, the distance and the speed.
The action runs once when the state is entered. Staying in the same state does not repeat it.
Nothing happens on an object that has never been damaged, because there is no damage information to work from. Make the transition into the state one of the “took damage” conditions.
The settings
Basis Type
Where “the other party’s position” is read from when calculating the direction you fly in.
| Option | What it is |
|---|---|
| Last Received Attack Area | Uses the origin of the attack collision that hit you (default) |
| Attacker Origin | Uses the origin of the object that made the attack |
For “attack area”, the origin of whichever attack collision is nearest to you is used. Since they overlap at the moment of the hit, the nearest collision can be taken as the one that connected. If the attack collision’s position cannot be obtained, it falls back to the attacker’s origin.
For attacks with no attacker object, such as barrage bullets, the bullet’s position is used whichever you pick.
The choice changes the result for long-reach attacks. Poked with a spear, “attack area” throws you away from the spear tip while “attacker origin” throws you away from their body.
Knockback Direction Type
| Option | Which way you fly | Mainly for |
|---|---|---|
| 360 Degrees | Along the exact direction from the reference point to you | Top view |
| Left Or Right | Straight sideways, to the side you are on as seen from the reference point | Side view |
| Launch | Away from the side you were hit from, at the angle you specify | Side view |
When the reference point and your own position coincide exactly, “360 Degrees” uses the rightward direction, and “Left Or Right” / “Launch” treat it as having been attacked from the direction you are facing and throw you to the opposite side.
Launch Angle
A field that only appears when you pick “Launch”.
| Value | Direction |
|---|---|
| 90 | Straight up |
| 45 | Diagonally up (default) |
| 0 | Horizontal |
| -90 | Straight down |
Attacked from the left at 45 degrees, you fly up and to the right. Which side you were attacked from is judged automatically, so you only need to specify the angle once.
Opposite Direction
Tick it and the direction you fly is reversed.
- “360 Degrees” … reversed by 180 degrees
- “Left Or Right” … left and right swap
- “Launch” … only left and right swap (the vertical direction is kept)
Use it for counters that charge into the attacker, or for a being-sucked-in look.
Distance
The knockback distance in pixels. The default is 0, so you must enter a value.
Move Speed Type
| Option | What else you specify |
|---|---|
| Object Speed | The speed multiplier (%), relative to the object’s movement speed |
| Completion Time | The completion time (seconds); it covers the distance in that time |
“Completion time” is the clearer one when you want a fixed distance and only want to change the speed. Specify “80 px in 0.2 seconds” and the character’s movement speed does not affect it.
Options
| Item | What it does |
|---|---|
| Pause Animation | Pauses animation during the knockback (for holding a single hurt frame) |
| Display Direction Opposite to Movement | Faces the opposite way to where you are flying (looking at the attacker while being thrown back) |
The display direction does not change by default. The original facing is kept through the knockback.
The visual script keeps running during the knockback. Actions still run and states still transition.
Worked examples
Getting knocked to the opposite side on touching an enemy (side view)
- Build a hurt state entered by “took damage”.
- Put “Knockback Self” in it and set:
- Basis Type: Last Received Attack Area
- Knockback Direction Type: Launch
- Launch Angle: 45
- Distance: 60
- Move Speed Type: Completion Time / Completion Time: 0.2
- Turn on “Pause Animation” to hold the hurt frame.
- Put something like “the action’s time has elapsed” on the transition to return to the normal state.
Being knocked in any direction (top view)
- Put “Knockback Self” in the hurt state.
- Set Knockback Direction Type to “360 Degrees”.
- Decide the distance and the speed.
It knocks you vertically as well, so use this one in top-down view.
Looking at the attacker while being thrown back
- Turn on “Display Direction Opposite to Movement”.
- You face the opposite way to where you are flying, which reads as still looking at the attacker.
Combining it with invincibility
- In the hurt state, enable the invincibility setting at the same time as “Knockback Self”.
- You take no further damage until the knockback finishes.
While invincible the damage information is not updated, so the direction you fly cannot change partway through.
Backing off slightly when an attack is guarded
- Put “Knockback Self” into the state entered when a guard succeeds.
- Make the distance small (around 10–20 px) and the completion time short (around 0.1 seconds).
- Leave “Pause Animation” off so the guard motion continues.
Things to watch out for
- Nothing happens if the object has never been damaged, because there is no damage information to work from. Put it in a state entered by “took damage”.
- The default distance is 0. Forget to set it and the action runs while nothing flies.
- What is recorded is the information for “the last attack received”. Run this action some time after the hit and you fly relative to the position at the moment of the hit, not where the attacker is now.
- “360 Degrees” also throws you vertically in side view. Use “Left Or Right” or “Launch” in a side-scrolling game.
- “Launch”'s opposite direction only reverses left and right. To flip the vertical direction, enter a negative launch angle.
- For attacks with no attacker object, such as barrage bullets, the basis type makes no difference. Both use the bullet’s position.
- If the reference point and you overlap completely, the direction is inferred from the display direction. Ways of being hit that come from straight above or below can throw you to an unintended side.
- The visual script does not stop during the knockback. If you do not want movement accepted, combine it with a setting on the hurt state that disables input.
- It is a forced move, so a wall stops it. It does not necessarily travel the full distance.
- Gimmicks (spikes, lava) have no knockback setting of their own. To be thrown back by a gimmick, put this action on the receiving side too.