Im trying to edit the CharacterMotor script for the FirstPersonController so that when the player collides with an object the players speed is increased.
Below is the edited part of the script that isnt working…
The CharacterMotor is a very complicated script. Editing it isn’t a good idea - believe me, I tried a lot, and most times had only undesired side effects. In this case, maxForwardSpeed is just the speed limit, not the character speed. I suggest you to replace the original scripts with this one:
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
It’s much easier to alter than the original CharacterMotor - just add this script to your character and disable CharacterMotor.js and FPSInputController.js.