Strange player behaviour after deleting platform obj


I’m trying to create exploding crates that the player activates when he collides with them. Once activated he has a short time to get away before the crate object is destroyed and is replaced by an explosion object which if he collides with it he gets injured (for the moment I’m just changing his opacity for 1 second).
It works ok except that if he does get hit he behaves strangely afterwards; can’t jump very high, he floats down very slowly and plays the animations associated with being on the floor. When he is on a platform again he runs at a normal speed but still can’t jump very high, even when he’s on the springboard that changes his jump speed to 1600.

I’m using the platform automatism for the crate object because I want him to be able to run across and jump between crates. If I remove the automatism everything is fine - he can get hit and continue to jump and fall normally. But this means he just goes straight through the crates. I don’t want to do an automatic jump when he lands on a crate as that would defeat my aim. I’ve tried using “Activate automatism of Crate: no” before destroying it but it doesn’t change anything.

It’s driving me nuts :cry:
What am I not getting here?

Why do you delete timer “CrateExplose” from memory in line 18 and “CrateExplosion” in line 20?
Are both of the created earlier in the code or are they maybe created “at the beginning of the scene”?

I’m using “CrateExplose” to delay the explosion and “CrateExplosion” for the duration of the explosion. They are not created earlier in the code or at the beginning of the scene. I’m deleting them because I was assuming (incorrectly?) that I’m creating instances of timers and that it’s a good idea to clear them from memory when no longer needed. I haven’t noticed a change of behavior of the crates since adding it but then this is just a sandpit for coding the events for basic behaviors and so I’m not displaying hundreds of crates. But following your question and my suspicion I’m now wondering if each instance of the object crate shouldn’t have its own timer object. Otherwise if it’s the same timer for all the crates the second crate will explode immediately if the player lands on it within 0.3 seconds of colliding with the 1st crate. A reset could delay the explosion of the 1st… Hum… I need to think this through.

But one thing I’m sure of is that it has nothing to do with the problem of the player behaving like it’s sort of on a platform all the time after being hit because adding those 2 deletes didn’t make any difference here.

It would be nice to be able to find a list of the actions with their usage and the values they accept. I had to poke around to find that the damping factor in the “Add a force to” action accepts floats and not just integers. Same thing for the opacity, I had to dig around to find that the values are from 0 to 255 and not 0 to 100 (like in the Gimp for example).

Maybe there is more to find in the codelines which you didn’t provide so far?

I’ve deactivated all the code for the other objects and so now have just the code for the crate and the Player 'and the problem persists) :

Object variable: Hit, default value: 0

The object ExplodingCrate has 0 automatisms.

And it’s only if he collides with the ExplodingCrate , if he moves away before the explosion and therefore doesn’t get Hit (object variable) then there is no problem.

My English is so bad these days I’m struggling to follow this thread. :confused:

Anyway, are you adding a force to the player using the standard object forces? I found this can cause a problem in platformer games. You can try to add forces to the player using only physics automatism and see if that fixes it.

That is what I did in this game:

And it seemed to work out.

He doesn’t use the physic automatism, so it’s a bad idea to use them.

Hi Mats,

I’m using the standard movements with standard keys for the player.
The problem seems to be coming from deleting a platform object. I’ve tried playing with simple platforms that move down when walked on, no timers. It’s fine unless I delete one of them then I get the same weird behavior from the player.

I’m going to try and find a work around without using platform automatism for my crates.
I’ve already taken out the lines of code that were trying to change the value of a variable of an object that I’d already deleted :blush:

I checked out your video, it’s cute. I’m using the same resources except for my player and some collectibles.
Does the platform that rolls out after pressing the lever roll back in again if you press the lever again?

It seems that using the platformer automatism the way you do, all created objects are some kind of a platform (or ladder if declared so).
You want the crates to be a platform, but you don’t want your explosion to be a platform.
As long as object exploding crate uses platformer automatism, it seems to be a platform.

Except that the object “exploding crate” does not use the platformer automatism, it’s a simple sprite object.
Simply put:
a crate object is displayed (sprite object with platformer automatism)
the player collides with it which sets off timer1
timer1 gets to 0 → an “explosion” object (simple sprite object, no automatism) is created at the same location as the crate
the original crate object is destroyed and timer2 is triggered
at the end of timer2 the “explosion” is destroyed
if the player doesn’t collide with the explosion object, no problem
if he collides with the explosion object, problem

I 'm now using simple sprites which have their own timer variable as described somewhere else on this forum and it’s working fine. But it would be nice to be able to destroy platform objects.

Ok, I see what goes wrong (and I’m able to reproduce it), it’s a bug (only with HTML5 platformer automatism, not in native one).
I’ll put a bug report on Github. :wink:

Great, thanks. :slight_smile:

By the way, you can move the player by some pixels up before deleting a platform to avoid the issue (which should still be solved).