- Home /
Question by
JuanseCoello · Jul 27, 2013 at 12:14 AM ·
charactercontrollerjumptimermovedelay
How can I set a timer?
When my character is jumping, I want the jump to delay half a second. This is my code:
public void Jump()
{
if (TP_Controller.CharacterController.isGrounded)
VerticalVelocity = JumpSpeed;
}
void HandleActionInput()
{
if (Input.GetKey(KeyCode.Space))
{
Jump();
}
void Jump()
{
TP_Motor.Instance.Jump();
}
Comment
Answer by Quantum2 · Jul 27, 2013 at 12:16 AM
public void Jump()
{
if (TP_Controller.CharacterController.isGrounded)
VerticalVelocity = JumpSpeed;
}
void HandleActionInput()
{
if (Input.GetKey(KeyCode.Space))
{
StartCoroutine(DelayedJump());
}
void Jump()
{
TP_Motor.Instance.Jump();
}
IEnumerator DelayedJump () {
yield return new WaitForSeconds(0.5f);
Jump();
}
It doesnt works. $$anonymous$$aybe if you explain to me what you are trying to do, or if I post more code we can solve this out. :(