Let’s add behaviors to Game Objects - GDevelop Tutorial



In our previous lesson we learned how to add objects to a game scene. In this lesson we are going to add behaviors for those objects. Adding behaviors gives life to those objects. For instance, we need to add gravity, collision and player controls to make the game work. If you hit Preview button (image 1) will load the preview of the game as a popup. You’ll see the player is floating in the air and if you press arrow keys, player won’t respond. This isn’t how it should be.
Image 1
Well this isn’t an easy task. It involves lots of lines of coding. But, fortunately, GDevelop have most of those features prebuilt as behaviors which saves our time.

Step 1

In the object panel, click three dots like button (menu) next to “Bob”. From the drop down menu select Edit Object.


In the popup, switch to Behavior tab and click ADD A BEHAVIOR TO THE OBJECT + button. From the behavior list select “Platformer character”. This will add some options to our player object’s behavior. You can change those values as you like. For now, we’ll keep those settings as it is. Click APPLY to add the behavior to the object.



Now if you hit the Preview button, the player will fall off the screen. Actually it should land on the platform we created. Instead the player falls through the platform. Let’s fix this.

Step 2

This time we need to add behavior “GrassTile” object. Go to edit object in “GrassTile” as we did in “Bob” object. Switch to behavior tab and click ADD A BEHAVIOR TO THE OBJECT + button. Here we are going to select “Platform” behavior. This will also add some settings to “GrassTile” behavior. At the moment we’ll keep those settings as it is and click APPLY to add the behavior to “GrassTile”.

Now hit Preview button to preview the changes. Bingo! Our player landed on the platform. Now use standard platformer game controls on your keyboard to move your player; Use left and right arrow keys to move the player back and forth. Use Shift or Space to jump.


Congratulations! You just step in to game development. You may notice that when you move the player, it doesn’t change to walking animation. Well, we are going to learn it in the next lesson.