Tutorial 06 Collide with ease

Written by Maaike on 25/07/2016 14:09:36

In our last tutorial Walking with bunny, we taught you how to make your character move by using keys. Today we are going to step it up a little by making our character jump and pulling some walls and floors up to collide with. 

Cover - end result tutorial

Step 1

Start with making the surrounding of the game. In our case that will be a floor, which you can make by adding some images. You can change the image to one in the public bundles if you want. You can copy the first image by selecting it and then drag it with ctrl aside. Place some of the objects a little lower and higher to force your player to jump.

Give all the blocks the same name, we will need that later on. You could use border.

Besides the surrounding we also need a character that will walk in our surrounding. In the bundle tutorial you can find a bunny or you can use one out of the public bundles.

Step 1 - surroundings

Step 2

To make our bunny walk, we need three sensors and three forces. One pair of a sensor and a force to go left, one pair to go right and the last pair to go up to be able to jump.

In our tutorial Walking with bunny you can find the explanation on how to use the sensors and forces. Place the forces outside of the game, connect them to the player and add a force. Place the sensors nearby the forces and choose the buttons you want to use.

Step 2- adding forces

Step 3

Now that our player can move around in the game, you shall see that when you play the game the player walks over the objects we placed instead of on top of them. To prevent this to happen we need to add a collision (element). Turn the material of the collision to solid.

With the collsion set on solid, we need to tell what will be exactly solid. You can fill in the name of the object at target. In our case that is: =#border

Also we need to let the collision know for whom it counts. In this game we want our player to be unable to go through the floor. At elements you add the name of your player: =#Player

Step 3 collision settingsStep 4

Our player can now walk over the floor you’ve created without being able to sink through it. But when he jumps, he will fly. To keep our player to the ground, when the jumping button is not in use we need an extra force.

In contrast to our earlier forces, we leave the fourth force on enable. It should be active on all times. You can give this force a strength in the y-as to make him go down, like 1.5 (we gave our jumping force a -3).

Step 5

Almost there. Our player can now walk and jump, is unable to go through the ground and when he stops jumping he will land on the floor. But he can still fly away out of the game, because the sides and the top is open. We need to close these openings.

To prevent that from happening we need to add boundaries. Add some images and make them the shape of a beam and place them vertical on the right and left side. Also make a horizontal beam in de air, so it creates some kind of roof. To make that the player can’t go through them, you give them the same name as the quares: as the blocks: border.

Last thing to do, is to make those walls and roof invisible, because of course we don’t want our players to see them. In the element settings of the walls and the roof you turn visible off.

Step 5 - boundaries


Well done! You have accomplished a new part of making a game.

During this tutorial you’ve learnt:
- Making invisible walls
- Letting a character walk up and down the road and even let it jump
- Work with collision and gravity

Please share your creations with us, we would love to see what other games you come up with. Good luck!