[SOLVED]Determining if character is off the ground

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

[SOLVED]Determining if character is off the ground

Post by Garold »

What is the most efficient way to determine if my character is on the ground or is in the air?

When my character is in the air I want to turn off sprinting. Here he is still sprinting during a jump. http://youtu.be/cHKFOEqnYgQ

I looked in CharacterController for what happens when he tries to jump. Should I check SupportFinder.HasTraction and SupportFinder.HasSupport? Is this best way considering I need to check each update? Or is there a simpler way? Or is this very efficient anyway?

Thanks again.
Last edited by Garold on Mon Feb 13, 2012 10:47 pm, edited 1 time in total.
BEPUphysics rules my world
http://cloneofduty.com
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Determining if character is off the ground

Post by Norbo »

Checking the SupportFinder's HasTraction property would do the trick. If the character has any objects where his feet are, including steep slopes, HasSupport is true. HasTraction goes beyond that and requires that the support also has a gentle enough slope that it can be stood upon stably. By checking HasTraction as a requirement for sprinting, the character won't be able to sprint while sliding chaotically down a steep mountain or while in the air.

The HasTraction/Support properties are simple no-calculation boolean getters, so using them every frame is perfectly fine.
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

Re: [SOLVED]Determining if character is off the ground

Post by Garold »

I used SupportFinder.HasSupport to check if the character was on the ground. It works very well as you can see here http://youtu.be/DGAs5IvjT-M

In addition, thank you for pointing out the differences between SupportFinder.HasSupport and SupportFinder.HasTraction. I now only check HasSupport. When my character walks down a slope he slides towards the end and misses a footstep, as you can see here http://youtu.be/QY4Q0HNNAyY

Once again, thank you very much for your time and your knowledge.
BEPUphysics rules my world
http://cloneofduty.com
Post Reply