Explain variables to newbie

Hi guys. I’m just download GDeveloper few days ago. Can anyone explain to what is variable (global, object, scene) and how and when to use it. And also what the purposes of using the ‘hitbox’ to animate the player?

1 Like

Welcome to the community Katsura. I think the Game Making Concepts has a section at the bottom explaining variables, but I’ll try my best to explain them.

GDevelop works by having 1 or more scenes in a game. A scene can be a title screen or a level in your game. Global variables exist and can be remembered across different scenes. A global variable that you change in level one, will still hold that value in level two. You could use the global variable to store the player’s score across different levels.

Scene variables are only available for each scene/level and are not stored when changing scenes. An example would be to have a variable to store whether or not a level has been paused.

Object variables are attached directly to the objects, and each instance of an object can have the object variable stored independently from each other. Say you have two instances of the same enemy object in your level. You could use an object variable to track their health when they are damaged and when the variable on that instance/enemy hits 0, you can trigger an event that will only kill that one particular enemy.

As for the hitboxes, I believe it makes handing collisions and logic easier and gives you more freedom with animating sprites. (Someone else might be able to shed more light on that topic though).

Hope this helps!

3 Likes

One of the strongest point of Gdevelop is how the community is helpful and kind

5 Likes

Hey! First of all, welcome to GDevelop!
The variables questions was answered well by convictedweirdo, so I’m going to explain the usage of a separate hitbox object. First, understand tha it is not a nessecity. You don’t need to use that external hitbox. But in some cases, it can be useful.

  1. Flexibility: With such a hitbox, you can modify the hitbox without modifying the animation. Let’s say you want 2 hitboxes for one animation. You would have to duplicate the animation and make different hitboxes for each. Here you can just modify the hitbox object with events.

  2. Consistency: Let’s say you have mutiple frame sizes in animations, then you might have a slightly different default hitbox (as it depends on the image) or by making them not exactly the same while making them manually. Such an object hitbox doesn’t changes and is always the same, and that could prevent bugs from happenning because of an unconsistent hitbox.

  3. Debugging: You can make the hitbox visible for debugging at any time to see if it behaves like you want

I hope I helped you, good luck with creating your game with GDevelop!

1 Like