- Home /
Question by
slideinsideways · Aug 19, 2014 at 09:13 PM ·
charactermotor
I need an example of how to use a gui button to trigger a jump using the first person contolers character motor.
Comment
Answer by slideinsideways · Aug 19, 2014 at 09:53 PM
#pragma strict
var motor: CharacterMotor; // reference to the FPC script
function Start () {
motor = GetComponent(CharacterMotor);
motor.useFixedUpdate = true;
}
private var jumpTime: float = 0;
function JumpMe(){
jumpTime = Time.time + 0.1; // send a 0.1s jump command
}
function LateUpdate () {
// send jump command during the time specified:
motor.inputJump |= jumpTime > Time.time;
}