Feature Focus is a series of blog posts and videos where we occasionally highlight some of the best features of Construct. In this feature focus, we'll cover the Platform movement behavior. It lets you instantly make a jump-and-run style game, while supporting advanced features and customization!
In case you missed it our last feature focus covered the Layout View.
Making a platform game
It couldn't be easier to set up your platform movement. You need to add two behaviors to two objects in Construct:
- Add the Platform behavior to the player.
- Add the Solid behavior to anything you want the player to be able to stand on.
The image below shows what you need.
Hit preview and you can already run and jump!
Slopes
You can make solids at an angle, and the Platform behavior handles them automatically. This can be a difficult coding problem in other tools, but it just works out of the box in Construct.
Moving platforms
You can use another behavior like Sine to move a platform with the Solid behavior back and forth horizontally. The Platform behavior can also handle this no problem!
Jump-thrus
As the name suggests, the player can't pass through anything solid. If they jump up and hit a solid, they will bounce back down off it. Often you want another kind of platform that lets the player jump on to it from below. In Construct you can do this by adding the Jump-thru behavior to an object instead of the Solid behavior. In the video below you can see the difference. The blue bar has the Jump-thru behavior. The player can't jump past the solid, but can jump on top of the Jump-thru.
You can also add a button to make the player drop through a jump-thru with the Fall through action.
Double-jump
A common platform game feature is allowing a single extra jump while in mid-air. You can enable this by enabling the Double-jump option in the Platform behavior properties. That's it!
Jump sustain
Another nice feature is the ability to have a variable jump height, jumping higher the longer you hold down the jump button (up to a limit). This means quick taps do a small jump, and holding down does a larger jump. Again this is easy to do - set a Jump sustain time in the Platform behavior properties and it works right away.
Changing gravity angle
Despite how easy it is to set up, the Platform behavior is also incredibly powerful. One of the advanced features is you can change the direction of gravity! For example you could make a game where gravity changes to different angles as part of a puzzle, or make a mind-bending rotating platformer like the one shown below. And all the other features like slopes and jump-thrus still work no matter the gravity angle.
Lots more
The Platform behavior gives you full control over the movement so you can completely customize it to your needs. You can of course add custom controls using the Keyboard object and the Simulate control action. There's animation triggers to make it easy to set the right animation for the player. The Platform movement can run along solids with mesh distortion allowing for more advanced level design. You can also modify the X and Y movement vectors to any value at any time, such as allowing additional jumps based on powerups, sliding down and jumping off walls, temporarily removing gravity, implementing "coyote time" and jump buffering, and much more. And whatever you do, the Platform behavior will automatically handle solids and jump-thrus with a robust and battle-tested movement algorithm that's been used in thousands of games and refined for years.
Examples
Construct's Example Browser has over 60 examples using the Platform behavior in a wide variety of ways, ranging from wall jump and jetpacks to block breaking and rewinding time. Filter by the Platform behavior (under the category Behaviors - Movements) in the Example Browser to see the full list. Here's a few to get you started! Click the links to open them directly in Construct.
- Platformer barebones template - an example with placeholder art demonstrating some of the features covered here like solids, slopes, moving platforms and jump-thrus.
- Mesh platforms - see how you can run along solids warped with the mesh distortion feature, allowing for more creative level designs.
- Cannon launch - jump in to cannons to launch yourself from them!
- Jetpack - use a jetpack to help you get around, but don't run out of fuel!
- Rotating platformer - try out the mind-bending gravity-altering example for yourself.
- Wall jump - demonstrates how to add a wall-jump capability to the Platform behavior.
Video tour
We've also got a video that takes you through many of these features. Check it out below!
Conclusion
The Platform behavior epitomizes Construct: easy for complete beginners to get started with, but with a depth of features and capabilities that allows for advanced users to get full creative expression. Many tasks that require complicated coding in other tools are built in and work by default in Construct, including handling all the complicated logic of slopes, moving platforms and even changing the angle of gravity. Even for things that are not built in, you can still customize the behavior to get exactly what you want, often with just a few event blocks.
Interested to learn more? Try the How to make a Platform game tutorial!