About this manual
This manual explains the features in ACTION GAME MAKER for working with the mouse and the analog stick.
How the mouse and stick work in ACTION GAME MAKER
Button presses are handled by “InputCondition”, but input that carries a direction and a magnitude — mouse coordinates, how far a stick is pushed — cannot be handled by that alone. These are the features for that.
| Feature | Kind | What it does |
|---|---|---|
| MouseInput | Condition | Tests the state of the mouse buttons, where the cursor is, and whether it moved |
| GetMouseInput | Action | Puts the cursor’s coordinates, movement, and the angle and distance from you into variables |
| GetStickInput | Action | Puts the stick’s angle, strength and X/Y components into variables |
| ChangeAngleSettings | Settings node | Rotates a node to match the direction of the cursor or the stick |
Existing features also have options for using the mouse and stick (see “Using them with other features” below).
Note that mouse coordinates change depending on “which layer you view them from”. When dealing with world coordinates, the correct approach is to take them relative to the object itself. All four of these features calculate relative to yourself (the object running them).
“MouseInput”
The condition for the mouse. It is in the “Mouse” category under “Add Other Condition”.
- Check Type: choose from “button state”, “the cursor is over me”, “the cursor is over a specified object”, “the cursor is in a specified region” or “the cursor moved”.
- Mouse Button: with “button state”, choose from “left button”, “right button”, “middle button”, “extra button 1” or “extra button 2”. The wheel cannot be used.
- Input condition: choose from “held”, “the moment it was pressed”, “released” or “the moment it was released”.
- Accept Frame Count: how many frames count as “the moment”.
- Detection Shape: what is used to test whether the cursor is over something. Choose from “wall collision”, “hit collision” or “a given radius”. Disabled collisions do not count.
- Detection Radius: the radius (px) for “a given radius”. It is measured from the object’s origin.
- Target object path: the target for “the cursor is over a specified object”.
- Region to test / the region’s basis: the region for “the cursor is in a specified region”, and what it is relative to (“screen coordinates” or “world coordinates”).
- Movement Threshold: with “the cursor moved”, how many px on screen count as having moved.
Test mouse buttons with this condition. A mouse button routed through an input condition (the input map) does not respond for the second player onwards.
“GetMouseInput”
The action that puts cursor information into variables. It is in the “Switch/Variable” category under “Add Other Action”. It assigns every frame, so whatever uses the values always sees the latest cursor information.
- Destination: what the values are written to. Choose from “myself”, “a specified object”, “a specified locked object”, “the parent object”, “the last contacted object”, “an object on the shared board” or “a project variable”. You pick one for the whole action, and every value is written to that same target.
- Assign world X / Assign world Y: the cursor’s position in the game world. It is measured relative to you, so the layer you belong to is taken into account.
- Assign screen X / Assign screen Y: the cursor’s position on screen (px).
- Assign horizontal movement / Assign vertical movement: how far the cursor moved on screen since the previous frame (px).
- Assign angle: the angle from you to the cursor. 0 degrees is right and 90 degrees is down. While the cursor is on top of you the angle is undefined, so the previous value is kept.
- Assign distance: the distance from you to the cursor (px).
- The destination for each: for every item you ticked above, choose the variable name to write to.
“GetStickInput”
The action that puts analog stick input into variables. It is in the “Switch/Variable” category under “Add Other Action”. It assembles an input vector from the input actions assigned to up, down, left and right, applies a circular dead zone, and then assigns. Unlike a simple pressed-or-not test, this gives you an accurate angle and “how far it is pushed”.
- Up input / Down input / Left input / Right input: the input actions treated as each direction. You can pick from the actions added to the project’s input map.
- Deadzone: the dead zone applied as a circle. A negative value uses the average of the dead zones configured on the four input actions.
- Assign angle / its destination: the input’s angle (in degrees). 0 degrees is right and 90 degrees is down. While there is no input the angle is undefined, so the previous value is kept.
- Assign Strength / its destination: how far the stick is pushed, from 0.0 to 1.0. That lets you split walking and running by how far it is pushed.
- Assign X / Assign Y and their destinations: the input’s X and Y components, from -1.0 to 1.0. Positive X is right and positive Y is down.
“ChangeAngleSettings”
A settings node that rotates a node to match the direction of the cursor or the stick. Place it as a child of an object. Use it to aim a turret or a held weapon.
- Target Node: the node to rotate.
- Use the left stick / Use the right stick / Use the mouse: where the angle comes from.
- Use the movement direction: uses the object’s movement direction as the input. While it has not moved yet, the direction it is about to move in is used, so the angle applies from the moment it is created.
- Use the line of sight: uses the line of sight direction as the input.
- Base Angle: an adjustment to the angle. Specify how far the artwork’s front is from right (0 degrees). For artwork drawn facing up, enter -90.
- Is Add Node Rotation: turn it on to add to the node’s original angle.
- Upward Rotation Limit / Downward Rotation Limit: the range it can turn through. Setting both to 180 removes the limit.
Using them with other features
| Feature | Setting | What it does |
|---|---|---|
| MoveObject | Move type = mouse cursor | Moves toward the cursor’s position |
| MovementTemplates | Move template type = follow the mouse cursor | Keeps chasing the cursor. Turn off “snap to the cursor position” and it chases at the move speed |
| ChangeFaceDirection | Face the mouse coordinates | Points the line of sight at the cursor |
| Bullet trajectory (the bullet database) | Fly in the aim direction (stick / mouse) | Choose the aim source (left stick / right stick / mouse). You can also specify “use the mouse when the stick is not pushed” |
| ReleaseCarriedObject | Direction type = the aim direction | Same: choose the aim source |
Worked examples
Aiming and shooting with the mouse
- Put a “ChangeAngleSettings” under the player, point the target node at the gun node and turn on “Use the mouse”. If the artwork faces right, leave the base angle at 0.
- Set the bullet database’s trajectory to “Fly in the aim direction (stick / mouse)” and the aim source to “mouse”.
- Watch for “the moment it was pressed” on the left button with a “MouseInput” condition, and transition to the firing action.
Supporting both stick and mouse
- Set the bullet’s aim source to “right stick” and turn on “use the mouse when the stick is not pushed”.
- If the stick is pushed it fires that way; if not, it fires toward the cursor. Players can use either a controller or a mouse.
An object that reacts to a click
- Use a “MouseInput” condition with the check type set to “the cursor is over me”. “Hit collision” or “a given radius” are the easiest detection shapes to work with.
- Add another “MouseInput” condition (button state, left button, the moment it was pressed) on the same node, and react when both are satisfied.
An enemy that chases the cursor
- Choose “follow the mouse cursor” in MovementTemplates and turn off “snap to the cursor position” so it chases at the move speed.
- Turn it on if you want it glued to the cursor (making the object the cursor itself).
Splitting walking and running by how far the stick is pushed
- Put the strength into a variable with “GetStickInput”.
- Watch for “strength of 0.7 or more” with a variable condition and transition to the running action.
Things to watch out for
- Use the “MouseInput” condition to test mouse buttons. Registering a mouse button in the input map and reading it with an input condition does not respond for the second player onwards.
- World coordinates change with the position (layer) you view them from. A world coordinate put into a single variable will not line up if an object on a different layer uses it as-is. Re-reading it with “GetMouseInput” on each object that needs coordinates is the reliable approach.
- If an object glued to the cursor is the camera’s follow target, the camera and the object push each other and diverge, which can send the view flying. Use both the camera’s “Drag Margin” and “Position Smoothing” (both are on by default in a new project). “Limit” makes it worse.
- An angle is undefined with no input, so the previous value is kept during that time (it does not return to 0 degrees). To make “no input” a condition, look at the strength or the distance instead.
- A stick’s dead zone is set per input action in the project settings. “GetStickInput” lets you specify the dead zone as a circle, so tune it there if diagonal input does not feel right.
- The wheel’s press and release arrive on the same frame, so it cannot be used with the “MouseInput” condition.