Here is the jumping mechanic I want to make using the Physics Engine:
You move on the ground with the left and right keys on the keyboard if you just press them normally. However, when you hold down the spacebar (which works sort of like a function key), the left and right keys will make the player jump in the proper direction instead of moving on the ground (a crouching animation is played too, ready to launch). And the longer you hold the arrow keys, the further you’ll jump (of course there’s a limit at which you’ll automatically start falling). When the spacebar is pressed during movement, the player immediately stops, and the direction keys have to be released and pressed again for a jump (releasing the spacebar will make the player keep running). You can’t move in the air at all or climb on walls, but you do bounce back from them. You can keep holding the arrow keys until landing to immediately start running, but you can’t hold the spacebar to keep jumping. To simplify it:
LEFT: move left
RIGHT: move right
SPACE: crouch (triggers to jump mode)
SPACE + LEFT: jump left
SPACE + RIGHT: jump right
Hi, it seems you have a quite clear idea of what you want to do. What is actually your question or what of the things you describe is problematic to implement for you?
There is this short tutorial that introduces you to some of the physics concepts and shows also some events that may be useful. https://www.youtube.com/watch?v=HzAFMb_q-a4
I would start getting the player to move to the right and left. Then implementing a jump etc.
Of course I have no idea what kind of game you want to make and I am most likely wrong, but just by looking at your requirements, it reads as if you want to have very precise controls of your player character. Physics based games often use the unpredictable or varying interactions of objects as a mechanic which you seemingly try to avoid?
There is also some contradiction in your description:
but:
The actual platformer behavior would offer you most of the stuff you need to control your player precisely out of the box. It doesn’t work well with the physics engine though. So what I just would like you to think about: do you really need a physics simulation for your game?
Hey, thanks for your reply, I’ll watch that video. I can make the player run, but I just have no idea about the jumping part, that’s what I need help with. And what I mean by not being able to move in the air is that after you leave the ground, the longer you hold the arrow key, the longer you’ll jump. But once you leave the ground, you cannot change directions, and when you start falling and it seems like you jumped too far and you are going to miss the platform, you cannot slow down or go the other way, it just follows a trajectory (maybe like 60° jump angle idk). And to really make it clear: you don’t jump with space. Space actives a variable or something, player crouches, and imagine as if now you had two jump keys, left arrow key and right arrow key - and you can jump lightly. There are so many key press combinations which all have to be fixed, but the mechanic itself is actually really simple. There are four ways to move but you only have two buttons, so you use space to switch between these behaviors, except it’s not toggle, you have to hold it. And yes the whole jumping part is where I’m stuck. Finally, it’s important that no, I cannot use Platformer for my game. There are so many reasons, here are the main ones I couldn’t do in the simple platformer:
There’s already a little delay when changing directions like I’m walking on ice, but I don’t think I can change friction there.
I’m walking on the slopes. Yes the game also has slopes (tho only 45°), and I want the player to slide down on it without being able to move. In Platformer, the slope has a terrible hitbox and I could find a way to slide down smoothly.
I can’t modify the jumping angle and make a custom trajectory. Gravity and jump speed don’t help here, it already jumps high but not far enough.
I can only recommend to look into the platform character movement options again:
You can set the Acceleration and the Deceleration of the character. If the Deceleration is lower than the Acceleration your character will slide like on ice. If you increase the Deceleration, it will immediately stop.
You can set the collision mask of your slope sprites and if this is not working well, you could make a bigger sprite as a collision mask. It can be a bit tedious but it should be possible to have the character slide down smoothly. If the player shouldn’t have any control over the character while sliding, you could even consider using a tween for making the slide effect.
You can definitely change the trajectory of the jump with gravity, jump speed and so on. To make it easier to find the right values for the different parameters you can use the platformer jump-evaluator which is part of Gdevelop’s example projects: GDevelop 5
You wrote that there are more issues for you with the platformer behavior which you hope to fix with the physics based movement. The tricky thing with the physics engine is that it is definitely not easier to make things work and it sounds a bit like overkill to make a physics simulation just for better character controls, but in the end you decide, of course, what you want to do.
Thank you this was really helpful! Now the player doesn’t slide after running, but it still does after landing, which is even more important. And now I have a good gravity and jump speed, it jumps high enough but not far enough, so only the angle is the issue. I couldn’t fix the slope yet but I’ll try, now I decided to keep everything I’ve done so far in platformer because I see it is possible. So those two things are left, plus something very important which I couldn’t make in platformer. It’s the wall bounce (not to be confused with the wall jump), whenever you touch the sides of the blocks, you would bounce back, for example if you are still going upwards when touching the block, you’d bounce back and still go up until releasing the button. And it’s really hard because this means that a single platform object’s four sides have to work differently. You can stand on the top, and bounce back from the sides and the bottom (when you touch the bottom, you would fall down earlier, in a different angle, almost completely straight downwards). And this part really feels possible only with the Physics Engine. Another one is the lightly jump. I already finished that part, when I release the arrow keys during a jump, it’s supposed to make the player fall, however it always goes up to the same height. These are the last things I need, I’ll fix all the little bugs (hopefully), but if you know the solution to the wall bounce or the lightly jump I’d appreciate some further help! Thanks anyways! It’s slowly getting better!
Edit: jump angle fixed
If I try that with increased deceleration this does not happen. Maybe this is because of your specific jump mechanic?
Bouncing from the ceiling shouldn’t be a problem as this happens already when you jump against a platform from below. Bouncing from the sides could be a bigger issue though.
Anyway, I would suggest to implement one thing after another and if you get stuck you could ask here. There is a big chance that someone can make a suggestion or even give you the events for solving your problem.
Yeah I immediately disabled the standard platformer movements to be able to make my own, probably that’s the issue. But I think I can finish it from here! That jump evaluator was really helpful, so thanks for that