RigidbodyFPSWalker climbing walls


I am using a rigidbody fps controller with this script : http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker and it seems to be able to climb up walls if you hold the w key, face the wall front on and spam the space bar. Does anybody know how I could fix this? Or is there a better rigidbody fps Controller that i could use? I need it to be rigidbody because it needs to interact with other rigidbodies and i need to apply Physics.gravity to it.

Thnx in advance.

ok there are two simple solutions, you could change you rigidbody movement for character controller movement (see character controller in script reference), and you can keep the rigidbody

Character Controller

Or you could set cubes near the walls, just turn off the renderer, for invisible cubes, is no the best option but that could help.

feel free to send me private message if you need more help.

As a solution I have made a little change in RigidbodyFPSWalker. Actually copied some code in it from CharacterMotor.

#pragma strict

var speed = 10.0;
var gravity = 10.0;
var maxVelocityChange = 10.0;
var canJump = true;
var jumpHeight = 2.0;
var jumpPerpAmount = 0.5;

private var grounded = false;
private var groundNormal: Vector3;
private var controller : CharacterController;
private var tooSteep: boolean = false;
@script RequireComponent(Rigidbody, CapsuleCollider, CharacterController)
function Awake () {
	rigidbody.freezeRotation = true;
	//rigidbody.useGravity = false;
	controller = GetComponent (CharacterController);
function FixedUpdate () {
	if (grounded) {
		if(!tooSteep) {
			// Calculate how fast we should be moving
			var targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
			targetVelocity = transform.TransformDirection(targetVelocity);
			targetVelocity *= speed;

			// Apply a force that attempts to reach our target velocity
			var velocity = rigidbody.velocity;
			var velocityChange = (targetVelocity - velocity);
			velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange);
			velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange);
			velocityChange.y = 0;
			rigidbody.AddForce(velocityChange, ForceMode.VelocityChange);
		// Jump
		if (canJump && Input.GetButton("Jump")) {
			rigidbody.velocity = Vector3(velocity.x, 0, velocity.z) + Vector3.Lerp(Vector3(0, 1, 0), groundNormal, jumpPerpAmount) * CalculateJumpVerticalSpeed();
	// We apply gravity manually for more tuning control
	rigidbody.AddForce(Vector3 (0, -gravity * rigidbody.mass, 0));
	grounded = false;
	groundNormal = Vector3(0, 0, 0);
	tooSteep = true;
function OnCollisionStay (collision : Collision) {
	for(var contact: ContactPoint in collision.contacts) {
		groundNormal += contact.normal;
		if(contact.normal.y > Mathf.Cos(controller.slopeLimit * Mathf.Deg2Rad)) {
			tooSteep = false;
	if(collision.contacts.Length > 0) {
		groundNormal /= collision.contacts.Length;
	grounded = true;
function CalculateJumpVerticalSpeed () {
	// From the jump height and gravity we deduce the upwards speed 
	// for the character to reach at the apex.
	return Mathf.Sqrt(2 * jumpHeight * gravity);