//Sprinting with the default fpscontroller in Unity 3.0
var sprintSpeed : float = 15;
var defaultSpeed : float = 10;
//sets default run speed
function Start () {
GetComponent(CharacterMotor).movement.maxForwardSpeed = defaultSpeed;
}
//When the sprint button is pressed, change speed to sprint
function Update () {
if (Input.GetButtonDown("Sprint")){
GetComponent(CharacterMotor).movement.maxForwardSpeed = sprintSpeed;
}
//When the sprint button is let up, change back to walk speed
if (Input.GetButtonUp("Sprint")){
GetComponent(CharacterMotor).movement.maxForwardSpeed = defaultSpeed;
}
}
Thursday, January 26, 2012
Sprint Script
Just a little script that makes the default FPS controller in unity have a sprint function.
Labels:
Scripts
Subscribe to:
Post Comments (Atom)
Thanks very much !
ReplyDelete