In some games, there are these “weak” or “falling” platforms that basically break a second after the player steps on them (Something like those doughnut lifts from Mario games).
In my game, I made a weak platform similar to what I said above. When the player stands on top of the platform, it will break after a second (It’s currently unfinished right now. No special effects yet)
However, there are some issues with the platform.
The weak platform is jumpthru, so when the player jumps on top of the platform from underneath, sometimes the platform doesn’t enter it’s breaking state. However, jumping in the air and landing back on the platform fixes it. I would like to make it so that if the player stands on top AT ALL, it breaks.
Additionally, if the player stands on top of a weak platform with another weak platform just one grid space above itself, then both weak platforms break. The only one that should break is the one the player is standing on, not the one the player is currently standing in front of.
Any help is appreciated ^^
why are you use “for each” event where isn’t needed, and why aren’t you use a “for each” event where it’s needed?
and why are you reset the timers of the unused instances always? why has the unused instances timers at all??
Please be more specific. You said that I used “for each” where it isn’t needed and didn’t use it where it should’ve been, but it isn’t enough information to know specifically which events you’re talking about.
Also, the timer is not ALWAYS reset. It only ALWAYS resets when the variable is 0. When the player steps on top, the variable changes to 1, which stops the timer from resetting. The reason the timer is necessary is because without it, the platforms sometimes disappear instantly when stepping on one of them from another.
Do you know the fix to this?
i think, but not sure. the only event thats need to be a “for each” is where you checking the value of the timers and delete the platforms. this should prevent undesired deletion of platforms. and because of this, the always resetting event becomes redundant.
and unnecessary to check the collision between the player hitbox and all instances of the platform, because normally it can only stand on one platform at a time. feel free to swap out the collision check to a normal event.
Not saying it will fix anything, but I would remove the first for each/reset timer block, and I would nest the last two blocks under a for each.
If you want, you can probably nest all the events under a single empty for each.
It’s possible that these are bugs, I remember seeing some issue about multiple instances sharing the same behavior. If you can reproduce the bugs in the platformer example, share the project and we’ll check it.
Okay, I recreated the example in a different project:
I was not able to recreate the other problem I was having, so here is a GIF of my problem (Notice how sometimes the platforms don’t break when I land on top) (I also apologize for the size and quality. The original GIF was too big to comment, and resizing it without an online resizer turned it into a still image, so this is the best I can provide)
Are there solutions to these problems?
Please try to upload you gif too https://giphy.com/ then copy and share the link, or just try Optimize animated GIF, because with the actual gif we can’t see the issue
I opened the project and didn’t see the issues you mention in your first post.
Regarding the issue you mention in the project, you need to add this line to avoid triggering the breaking when player is on the ground floor:
I don’t know if is this what you want to achieve, but in this project when the player collides with the platforms and is on the floor, nothing will happend
(So sorry for the late reply, I was recovering from wisdom teeth removal)
I downloaded the project and checked what you (And Gruk) did, but sadly, it didn’t help. Sure, it works if the player is on the ground, but if he’s standing in front of a breakblock while on top of another one, they both break.
Is there some sort of event I can use to check the player’s position for EACH block, so that each breakblock can check if the player is standing on top?
Also, here is the requested GIF. In my ACTUAL game, if the player jumps through the breakable platform just BARELY high enough to step on top, they don’t break. Otherwise, they work exactly the same as I’ve showed before. Is there a way to make them ALWAYS break? The code used in the actual project is the exact same used in the test project we’re sharing.
Looked at your example files. your events don’t quite make sense.
This right here will mean your animation will reset every frame once the variable is set to 1, probably not what you want.
At a quick glance, I think you need to ensure that only breakblocks that the player is directly on top of get “targeted”. This will likely involve checking the Y position of the player vs the block.
I made some quick changes and this seems to do the behavior you want, or at least get you closer:
Edit: This is probably cleaner, and will avoid potential conflicts if one block is updated earlier in the frame than another.
Thank you mate, this was exactly what I was looking for! A way to check the Y position of the player for each block! I just didn’t know how to execute it. My code looks a lot cleaner too! ^^
Unfortunately, the problem from the GIF above is still in effect, and I’m not sure how to fix it even with the improved code. Is there anything else I can add to make sure the blocks are GUARANTEED to break when the player steps on top? Thanks
In my example they always break. There’s never a situation where they don’t, at least not that I can recreate.
You’re not having troubles at all?
I’ve tested this in the shared project, and it always breaks too. I’m not sure why I get the error in my actual project.
Perhaps there’s something wrong with my player’s hitbox…
Correct. Works fully with your example project with the events I showed above. Here’s a screenshot of the whole event sheet:
Here’s a movie showing me clearing all of the platforms: (Link good for 24 hours) https://easyupload.io/y46pf6
Okay, thanks. I’ll tweak the code a bit