Controlling the Height of a Jump

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Menyueru
Posts: 17
Joined: Sun Jun 09, 2013 11:28 pm

Controlling the Height of a Jump

Post by Menyueru »

Hello, first of all i've just started to implement the Character Controller( not the latest build because i still need to be able to use Xna.Framework Vector classes, for Lindgren, and the latest version of your character controller uses BepuUtilities Vector classes), and i want to be able to Control a jump by it's height not by the speed of the jump, I'm simply thinking of having a value that saves where i was at the time of the jump, and then simply check if my current Y position - the Y position i saved is over the Max Jump Value, and at that moment i apply a big negative Y force. Basically what i'm asking is if you guys think my solution is plausible, or does the the Character Controller already has something that can help me with that, if it does please enligthen me, or if the other 2 are a no how do u think i should aproach this??

Thanks in advance :)

#Edit: Also how can i avoid my character going through the floor? I know my idea will make him probably go down, even further down, i was thinking is there anyway to avoid that?, and if not, how could i make something like u do with the StepManager and just make him teleport to the appropiate height so he is not stuck on the floor??

Also Twice the thanks in Advance
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Controlling the Height of a Jump

Post by Norbo »

i want to be able to Control a jump by it's height not by the speed of the jump
Rather than applying a discontinuous force to push it down, I recommend just directly computing the jump speed required to reach the desired jump height. Standard equations of projectile motion would do the trick.
#Edit: Also how can i avoid my character going through the floor? I know my idea will make him probably go down, even further down, i was thinking is there anyway to avoid that?, and if not, how could i make something like u do with the StepManager and just make him teleport to the appropiate height so he is not stuck on the floor??
Even with a large pushdown, the character should not get stuck in the floor. It uses continuous collision detection and the rest of the penetration should be resolved by regular collision response.
Menyueru
Posts: 17
Joined: Sun Jun 09, 2013 11:28 pm

Re: Controlling the Height of a Jump

Post by Menyueru »

Norbo wrote:
i want to be able to Control a jump by it's height not by the speed of the jump
Rather than applying a discontinuous force to push it down, I recommend just directly computing the jump speed required to reach the desired jump height. Standard equations of projectile motion would do the trick.
Yeah about that the problem is that in mid air there is a slight second where he feels like he is floating in midair i want him to come down the moment he gets there, also i want the jump to be really fast.
Norbo wrote:
#Edit: Also how can i avoid my character going through the floor? I know my idea will make him probably go down, even further down, i was thinking is there anyway to avoid that?, and if not, how could i make something like u do with the StepManager and just make him teleport to the appropiate height so he is not stuck on the floor??
Even with a large pushdown, the character should not get stuck in the floor. It uses continuous collision detection and the rest of the penetration should be resolved by regular collision response.
He doesn't get stuck but he does stay there for a second before recovering from the fall.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Controlling the Height of a Jump

Post by Norbo »

Yeah about that the problem is that in mid air there is a slight second where he feels like he is floating in midair i want him to come down the moment he gets there, also i want the jump to be really fast.
Increasing the effective gravity will make jumps faster in general. If you don't want higher gravity for other objects, an extra acceleration could be applied to the character body specifically by adding (0, -extraAcceleration * dt, 0) LinearVelocity each update.

If you want a very specific custom behavior, then yes, you'll need to apply appropriate forces.
He doesn't get stuck but he does stay there for a second before recovering from the fall.
Does 'stay there for a second' imply you cannot control the character? If so, that doesn't sound normal. There might be some configuration issue (scale, perhaps) or geometry issue. If you can reproduce the behavior in the latest BEPUphysicsDemos for me to look at, it could help.

If the character is still controllable throughout but the body just takes a fifth of a second to fully 'stand up' again, that's more expected. The speed of the depenetration could be increased using the CollisionResponse.MaximumPenetrationRecoverySpeed (that's a v1.3.0 name- I think it may be 'Correction' instead of 'Recovery' in v1.2.0).
Menyueru
Posts: 17
Joined: Sun Jun 09, 2013 11:28 pm

Re: Controlling the Height of a Jump

Post by Menyueru »

I've managed to fix the issue by putting a really high gravity value, and the other thing is more like he is under the floor for the quarter of a second but now that i check thouroghly he can move fine if i tell him to move after he comes back down.

Well thanks anyways Norbo :D

Also i need to be able to have some kind of control while i'm on air i'll be checking the character controller
Post Reply