#pragma strict

private var walker : CharacterMotor;
private var OrigJumpSpeed : float = 0.0;
private var OrigForwardSpeed : float = 0.0;
var JumpSpeed : float = 0.0;
var forwardSpeed : float = 5;
var forwardRunSpeed : float = 5;
var IsAutoJump = false;

function Start () {
	walker = this.GetComponent(typeof(CharacterMotor));
	OrigJumpSpeed = walker.jumping.baseHeight;
	OrigForwardSpeed = walker.movement.maxForwardSpeed;
}

function OnControllerColliderHit (hit : ControllerColliderHit) {
	if(hit.transform.tag == "Jumper"){
		yield WaitForSeconds(0.15);
		walker.jumping.baseHeight = JumpSpeed;
		if(FPCStatus.isRunning)
			walker.movement.maxForwardSpeed = forwardRunSpeed;
		else
			walker.movement.maxForwardSpeed = forwardSpeed;
		walker.inputJump = true;
		IsAutoJump = true;
	}
}

function Update(){
	if(IsAutoJump)
	 	RestoreOrigJump();
}

function RestoreOrigJump(){
	yield WaitForSeconds(0.1);
	if(walker.IsGrounded()){
		walker.jumping.baseHeight = OrigJumpSpeed;
		walker.movement.maxForwardSpeed = OrigForwardSpeed;
		IsAutoJump = false;
	}
}