Page 1 of 1

[SOLVED]Determining if character is off the ground

Posted: Mon Feb 13, 2012 8:24 pm
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.

Re: Determining if character is off the ground

Posted: Mon Feb 13, 2012 9:02 pm
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.

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

Posted: Mon Feb 13, 2012 10:53 pm
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.