- Home /
CharacterController and end of collision
Hi, I am making a 2d-platformer game in which the player can control gravity and have some issues regarding hit detection. As of now, I am using a CharacterController to move my character.
I need to be able to know when my character has left the ground. OnCollisionExit does not exist for CharacterController, so that won't help. The isGrounded function does not work, since the char could be walking on the ceiling or on walls. I guess I could find ways to code around that, but I was hoping there would be an easy/practical solution already.
Answer by Vønce · Oct 16, 2012 at 02:16 PM
I found a (in my eyes) decent solution, just checking the CollisionFlags that CharacterController.Move returns. Checking for CollisionFlags.None lets me know if the character has left the ground.
Answer by slayer29179 · Oct 16, 2012 at 12:48 PM
Hey Vønce ! You can use one of the controllers functions called isGrounded. Put this in your Update function!
if (controller.isGrounded)
{
{
else
{
//Gravity code
}
I think this should work? :)
Thanks for the reply, but as I stated isGrounded on it's own is not enough.
I must of missed that in your question. $$anonymous$$y mistake!
Your answer
Follow this Question
Related Questions
Is there a rigidbody character controller 3rd person that can handel stairs (steps)? 1 Answer
Any way to ignore collision between rigidbodies and colliders/character controllers? 1 Answer
Character Controller meets Rigidbody 1 Answer
Problem with character controller and collisions 1 Answer
Collision CharacterController vs CharacterController 2 Answers