How would one go about in making a character jump using physics instead of the platformer behavior?
Explanation: The platformer behavior is giving me some trouble due to some crouching animations that I have, and my character phases through the floor when I crouch (due to the hitbox changing sizes I believe). I tried using the Physics behavior and everything works fine, but I don’t know how to make the character jump properly (I’m very new at this).
Thank you for reading!
You could keep the platformer behavior turn default controls off, then you map the keys yourself:
Right key is pressed : Simulate right key press
Left key is pressed : Simulate left key press
Up key is pressed : Simulate jump key press
Down key is pressed : Change the animation
and if you still want to be able to drop through Jumpthru platforms, you could use something like this:
Down key is pressed AND Z key is pressed : Simulate down key press
I’ve already tried disabling the default controls for the platformer behavior, but it still bugs out with the crouching animation (the character falls through the floor).
Is it a passthu platform, or standard platform objects too?
It’s a standard platform.
In the simplest case, jumping using the Physics behaviour is just a question of increasing linear velocity on the Y axis when the jump button is pressed. The inbuilt gravity will return your player to the ground afterwards.
If you give your player object (called “Player” in the example below) an object variable called “jumpheight” (typical starting value might be -4) the you would have an action something like
Set linear velocity of Player to Player.Physics::LinearVelocityX();Player.Variable(jumpheight)
that you link to the condition of [ jump] key is pressed. You could just put the number -4 after the semi-colon, but a variable lets you change how high the player can jump at different times.
Although this works, it becomes more complicated if you want to prevent jumping in mid air.