User Tools

Site Tools


pushing

Pushing


The pushing mechanic allows characters to push and pull objects onto other tiles. This is a great way to include puzzles in your game! For example, a room could be set up where the player needs to move one or more boxes onto specific tiles in order to open a door.

Setting Up a Pushable Object

Add the object that you want to be pushable to an open tile on your map.

Ensure “Interact Only” navigation paths are connected from the object's tile to any adjacent tiles. This will allow the player to interact with the object, while also preventing them from walking through it.

Switch to Edit mode (F2), then double-click the object to open the Entity Properties panel. From the Entity Properties panel, enable the “Pushable” option. This will allow the player to grab onto the object from an adjacent tile. When an object is configured as pushable, you'll see a hand icon above it.

Set the desired movement speed for the object. The movement speed is measured in voxels per second and determines how fast a character will move when pushing or pulling the object.

If the pushable object should be restricted to, or prohibited from, certain tile types, you can make use of the terrain types option to do so. If the default option of “All” is used, the pushable object will be able to be pushed/pulled onto any tile (assuming the appropriate navigation paths exist).

Once the object is configured to be pushable, the player will be able to grab onto it from an adjacent tile and then push or pull it. As shown below, the game will automatically update any surrounding navigation paths whenever the player pushes or pulls the object onto a new tile.

Animation

When a character pushes or pulls an object, the game will automatically attempt to play the “push” or “pull” animation for that character. If a “pull” animation isn't defined, the game will use the “push” animation for both pushing and pulling. See Predefined Animation Names for more information.

Scripting

If desired, you can trigger events to occur as the player interacts with the object in various ways. There are tile scripts that can be triggered when a pushable object enters, exits, or stops on a tile. You can find more details about these events on the Entity Properties page. There are also global event scripts that are triggered when a character grabs, pushes, or releases an object.

As an example, the script below could be assigned to the “Object stops on tile” trigger for a special tile that the player needs to push a box onto. The script plays an animation for the box and removes all navigation paths surrounding it in order to lock it into place and prevent further interaction. This could be extended to perform additional actions, like opening a door to the next room.

replace_navigation(self, INTERACT_ONLY, NONE);
play_animation($object, "lock");

Game Controls

In-game, pushable objects can be controlled with either the mouse or keyboard (assuming both control types are enabled for your game).

To grab onto the object, either left-click on it or press “G” while standing on an adjacent tile. You can release it by either left-clicking on it again or pressing “G” again.

To push or pull the object with the keyboard, move the player character towards or away from it, respectively. To push the object with the mouse, left-click on an open tile in front of it onto which it can be moved. To pull the object with the mouse, left-click on an open tile behind it onto which the player character can walk. When pushing or pulling with the mouse, you can click on any tile in a straight line in front of the object as long as the entire path to that tile is open.

pushing.txt · Last modified: 2022/12/18 17:18 by justin