FPS Rigidbody Controller

Hi friends,

I need an FPS walker script that uses rigidbody rather than character controller, since I want to be able to rotate it.
I found this on the wiki:

and a slightly more advanced version here
http://forum.unity3d.com/viewtopic.php?t=3222
The problem with these scripts is that you can stick to the wall if you jump and hold on forward. The capsule will just stay in the air. I guess I would need a better way to check if I am grounded or not to get around this problem.
So I am looking for ideas how I can make one that is efficient and reliable.
I could check the collision points and normals but this might turn out a little heavy and may not be robust. Say just check if there is a collision point that is at the bottom of my capsule.
Another approach might be to have a second smaller collider underneath my capsule which ignores collisions with the capsule but detects them for everything else?
This seems like a common enough problem with no clear solution that I can think of so I decided to ask, what people do in this case?

thanks

1 Like

actually never mind. taking a closer look at the script in the link above (from the forum), it does have a check to see if the collision is happening from the bottom.

function TrackGrounded (col : Collision) 
{ 
   var minimumHeight = capsule.bounds.min.y + capsule.radius; 
   
   for (var c : ContactPoint in col.contacts) 
   { 
      if (c.point.y < minimumHeight-offset) 
      { 
         if (col.rigidbody) 
            groundVelocity = col.rigidbody.velocity; 
         else 
            groundVelocity = Vector3.zero; 
         grounded = true; 
         break
      } 
   }    
}

it was’t working for me as it was, but I only added a small offset, 0.5 in my case, to the check and now it seems to be working as expected.

1 Like