Help with game crash?

Please help. My game keeps crashing all of a sudden after a few seconds and I have no idea why. Can’t find the problem. :sweat: :sweat: :sweat:






Sorry if it’s a mess. I usually clean up in between sessions. :sleepy:

The in-game looks like this:

When I add in the moving platforms it crashes even faster.

These might be a red herring and not affect the game, but they’re things that I’d first check:

  1. Third screen shot, second to last event of the Game section, it looks like you are tweening every platform with no condition. This will be happening every single frame. Add a condition to check that the tween isn’t already playing.

  2. In the lava section, you tween the lava when the timer is over 20 seconds, and pause the timer. But it will stay over 20 seconds, and create the tween every single frame. Pause and reset the timer.

  3. When the player hits lava, the scene is paused and GameOver is started. Does the GameOver scene stop and resume the paused scene?

  4. First event of playerAnim section, again the tween could be created over multiple frames. Check the animation isn’t already playing as part of the conditions.

I found that the crash had something to do with the scaling of the player sprite, But does anyone know why though?

Ty so much, This will help optimise the game.

Ha, beat you by mere seconds :smiley: Yes, I think #4 will sort that one out.

You sure did :joy:

One more question? When I add a random value to a timer, Is that random value chosen each time the timer resets or only once? and if it is only once, How can I make it random each time the timer resets?

As in “Value of Timer is > RandomInRange(20,30)” ? In which case, the random number will change every frame.

ok cool, because I feel that Gdevelop’s random, isn’t really random? When I use random, the next chosen value is pretty close to the previous chosen value

That will depend on the size of your range. Smaller range, the closer the numbers will appear.

True, and I guess for now that can’t really be avoided.

You may be able to generate slightly more varied numbers utilising trunc(RandonFloatInRange(0,1) * RequiredRange)

How can I save Values. I remebered previously using the file system but now it looks different? I want to save Highscore and and load at the beginning as well as overwriting lower scores.

Thanks will try that.

I would have thought using the “Save a scene variable to to a JSON file” and “Load a scene variable from a JSON file” would do the trick. If you create a structure to hold all the variables to be saved (say called GameState), then you can use GameState as the variable, and all the variables under it will be written and read.

Ty, I’ll try that and come back to you.

It wont save the players score (integer) to the Json file. How do I convert the Integer to a text?

or else… How do I save and load player score using Json files?

Are you using Scene variables? I’ve got it working using this setup:

[edit]
And it loads back using "Load JSON from filename into scene variable GameState" (I set the integer variable to 0 and text to “No-one” to confim it gets loaded). Initially score is treated as a text, but as soon as it gets incremented it is converted into an int.

I moved over to using the Storage function but now it won’t save to storage.

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

2 Likes

Ok, I’ll see what i can do next time I work on that project again. Ty