Game crashes when touching platformer character

I’ve made a simple ball bouncing platformer character. But whenever I touch or click on the player the game crashes and restarts the scene. Below is a screenshot of my code. The game will crash on both Android and in the play in editor of Gdevelop.

You don’t have to put touch as ended and mouse button released at the same time, just ad LMB released and it will work on all platforms.
And what do you mean by touching the player? You mean the touch_button or the white_ball_player?

And you have put touch released as a sub event to touch started, a touch can not be started and released at the same time. So I suggest you to consider putting “LMB relased” as a regular event, not a sub event

It still crashes when touching or clicking on the ball character. If I touch it or click on it the game will crash. I replaced it with left mouse button released and it still crashes.

So I suggest you to consider putting “LMB relased” as a regular event, not a sub event

Have you tried this?

Yes, I already tried that. It still crashes when I touch the character. It doesn’t crash when touching anywhere else on the screen.

is this all your codes? Because there is no event about touching the white ball here.

This is not all my code. I don’t have any event for touching the white ball at all. The white ball is the only platformer character in the game and there is only supposed to be one touch event when touching the screen. I put a transparent button over the entire screen so when the player touches anywhere on the screen it will trigger that one button and jump up and down.

I recommend getting rid of the transparent button. Just use “touch or left mouse button down” it will do the same trick, your touch doesn’t have to be on any object.
If this doesn’t work either, try disabling your events one by one so you can see which event causes the problem.

It seems you have a problem with one of your actions. Check all the images and sounds, check that the ball has platformer behavior, and check that the objects exist on the scene.
If all fails, press ctrl-shift-i, and screenshot the console tab.

Why only show these events?

It looks like I found an issue in the console tab, but I don’t know how to fix it. It says “failed to parse Sourcemap” I don’t know what that is or how to fix it.

Update, I tried switching out the old sprite and adding a brand new one, but it still crashes. It only crashes when clicking on or touching the ball sprite platformer character. I can touch or click on anything else and the game performs fine, so I’m thinking it has to do with the platformer behavior.

I found the problem, but I don’t know the solution. The problem is the platformer behavior. When that’s removed I can touch the ball character just fine. But without the platformer behavior I would have to manually create jump, gravity and movement.

Do you have any other movement behaviors on your ball such as physics, top down, or otherwise?

(I’m pretty sure you cannot combine movement based behaviors.)

1 Like

Nope, I only have the one behavior. I deleted everything else. The only problem is the platformer behavior. The only time it crashes is when I touch the player ball. The game is perfectly fine in every other way, just this one glitch that gets in the way.

I’d recommend refactoring your code too. It may not make a difference to the bug, but it’ll make it cleaner and easier to read. For example, you’ve got two conditions that check for cursor/touch on touch_button, or a new touch has started. So they’ll both fire. The second one also allows a double jump. So it’ll do this regardless the animation number. Not sure if this is the behaviour you want.

With the same conditions, you’ve got a subevent that checks a touch has ended. But this will never happen if the touch has started triggered the condition.

Also, LMB click is simulated by a new touch on touch screens. So no need to check for start of touch , unless you intend to go multi touch.

Now, if it were me, I’d refactor and make one initial conditional event with the following conditions:
Trigger once
cursor/touch is on touch_button
LMB is clicked

Then have a 2 subevents (the order here is important, because otherwise you go into jump and then double jump one after the other):

subevent 1 condition : Number of animation = 2
subevent 1 actions : All the actions after the second comment

subevent 2 condition : Number of animation = 0
subevent 2 actions : All the actions between the two comments

I think this will achieve what you’re doing. It probably won’t fix your bug, but it no harm in cleaning up the code.

If the bug persists, strip down the actions to the basics - just simulate the key presses and nothing else. If that crashes, then the issue’s somewhere else. But if not, keep adding one action at a time and running the game, until it crashes again. At that point you’ll know what’s most likely causing the crash.

Also, make sure you only have one touch_button and white_ball_player on the scene - in the editor, click on the list of instances icon in the top right corner, and it’ll list all the objects in the scene.

Sadly, I can’t reproduce this issue with the default platformer.

Here’s an export preview, you can click on the player character and it’ll jump:

Here’s the event:

As a general heads up, you are using an “or” statement for your cursor is on and touch has started, which will mean any touch will activate those events, not just those on the ball object. I don’t think this is what you want. I think I have something closer to what you were intending.

The orange ones are warnings.
DevTools and Source map are one thing for the developer, there is nothing problematic here.

1 Like