Pushing rigidbody with FPS Controller

I am making an FPS using the FPS controller that comes with Unity. I have added this script:

// this script pushes all rigidbodies that the character touches
var pushPower = 2.0;
function OnControllerColliderHit (hit : ControllerColliderHit)
var body : Rigidbody = hit.collider.attachedRigidbody;
// no rigidbody
if (body == null || body.isKinematic)

// We dont want to push objects below us
if (hit.moveDirection.y < -0.3) 

// Calculate push direction from move direction, 
// we only push objects to the sides never up and down
var pushDir = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);

// If you know how fast your character is trying to move,
// then you can also multiply the push velocity by that.

// Apply the push
body.velocity = pushDir * pushPower;

It pushes the objects, but either its shaky, or it flips the object over. I just want a smooth push (like Source) . PLEASE HELP!

You just need to go to your rigidbody and Freeze Rotation for X, Y, and Z.

For a FPS, may I recommend using a character controller. Rigidbody is for enabling Unity’s true physics engine and will interact truthfully how a real life object might act.
Unity’s boot camp tutorial teaches A LOT of what you want to do for a FPS. I suggest following the tutorial for it, if any, if not then just dissect the code.


Have you tried using RigidBody.AddForce instead of changing the velocity of the RigidBody?

So try:

body.AddForce(pushDir * pushPower);

Haven’t tested as I’m not in front of my dev PC, but if you pass in the correct Vector3 to AddForce it should work.