Debug or Finding Errors

I have created a html type game. In the GDevelop program I can run it and it will show a simulation in a browser window. Is there anyway to see what lines of code are being activated as I play? I am having a strange action occurring in my game and finding it hard to find out where is the error.

AFAIK there is no easy way to debug it, you’ll have to break out your mind and try modifying the code, adding actions to know wich event is the problem, for example add the action to change the scene background color in an event that you suspect is running when it shouldn’t :slight_smile:

In addition, it is also useful if you can write the values on important variables of the screen. Writing all kinds of values (variables, or result of your calculations) can be very helpful.

You can do this by making text objects, and then at the correct places change the text value to ToString(VariableName) (if it is a number).

^^

It’s also a VERY good idea to put all your functions into external events and to keep your coding neat. You should decide on conventions and follow them at all times. For example, I always label variables in my games all_lower_case_with_underscore and I always add anything more than one line in length into sensibly labelled groups. Organizing code like this means that bug crushing, even in larger games, is a much more manageable task.
Example of organizing code:
https://postimg.org/image/85qx5jvof/

Thanks :slight_smile:

I usually use the ‘variable to txt box’ to check for errors but this time it isn’t finding the problem. I have a character who is running into an invisible object which is making a sound. I have checked the Instance list pregame and there is the correct number of object on screen. I am using the ‘variable to txt box’ to check for additional objects being created but the number is consistent. Objects do get deleted and put back on another ‘layer’ but none of those objects are missing or in the way of my player character on the below ‘layer’. It is doing my head in :confused:

Well I couldn’t find the error even though I suspected it was something to do with the deletion and recreation of the object at a new location on another layer. So I created duplicate objects and substituted that into the code. Funny enough it is fine now. Even though it works it would have been nice to find the problem in case it happens again :smiley: :smiley:

Check for collision between objects in different layers is not a easy, maybe you see that they are colliding, but could happen that the layers cameras are looking at different locations and the objects are far away from each other actually. GD will check the collision analitically (the positions and sizes) so there could be no collision :wink:

Can objects on separate layers collide?

Yeah, almost sure. If you have two layers A and B, and the cameras from the layers are located in the same position, they will be looking at the same position of the space, and if you see that an object in A is colliding with an object in B, is because they are colliding :slight_smile:
But if the camera of layer A is looking at position 0;0, and the camera of B is looking at 1000;0. You could see an object in A colliding with an object in B, but they are distanced by 1000 pixels actually… This happens because the cameras are in “different spaces”, but rendering on the same screen :neutral_face:

Ah, okay that makes sense. Thanks :slight_smile: