I’m making a platformer game that functions similarly to a sidescrolling mario game. In the game I have these brick objects that I want to have break when I jump into the bottom of them or dive into the top. I tried using collisions, but that would make the player lose their momentum, or cancel their jump/dive. I also tried using point collision, but that would only work if I was in the center of the object, and even then If I went to fast I would still collide with the block and cancel my dive.
If anyone has a good idea on how to make this work, please let me know. Thank you all!
(photo for reference)
This would be my first port of call, but you shouldn’t have at be at the centre of the object to detect it. Did you define a point below the player’s hitbox? Can you screen shot the defined point and the code you used to determine the object-breaking events?
Sorry I phrased this part wrong. What I meant was that the point was in the center of the player, just below the hitbox, so if the center doesn’t line up with the object, it doesn’t break.
I didn’t explain that too well so I’ll attach some images
If I need to explain what I mean better, please let me know
First, your game looks fun!
Second, in your video example it looks like the character’s center isn’t over the block. So, it makes sense to me that it wouldn’t break.
I haven’t tried to implement anything like this in my projects, but I assume if you made two more points to the sides of your first point below the character and moved them out just a little it would address most of your issues.
That being said, I kind of like what you have going on there and it seems to fit in the normal game world logic that I would have to hit near the center of the object I want to break. So for me personally I wouldn’t mind being able to smash down and not destroy the platform below if I position myself properly. I can avoid a hit and keep the platform.
I hope you’re able to get it working like you want though, keep it up ya legend!
That was my first thought too, but just to split the one point into two that are not quite the character width apart.
The problem with that is what happens if you land on the middle of two bricks? Do they both get destroyed? Or do you find the one nearest the character?
First of all, thank you for all the compliments and feedback! It really helps motivate me to continue working on this project.
I also can’t believe I didn’t think to put more than one point to detect the object, haha.
Second of all, this idea specifically, I love!
I decided to put the two points closer to the center so if you got close enough to the edge, you could dive without breaking the object.
This also inspired me to add a jump boost if you jumped right after you hit the ground.
I decided to test it and it destroys both! (how i intended it to work)
I just need to get it to work when I hit it from beneath. I assume it should work the same as the dive, except having the points above the hitbox.
I’ll try it in a few minutes, if it works I’ll mark this as solved.
[Edit]: It worked!