Deciding to jump based on zero velocity

Hi,
Since the toad is more or less stationary while grounded on the high friction surface, I’m just checking if the velocity is 0 to allow the jump. Anything wrong with this approach anybody?

private void PullTrigger()
{
    if (rb.velocity.magnitude == 0) {
        Vector3 projectionVector = Vector3.ProjectOnPlane(head.Gaze.direction, Vector3.up);
        Vector3 jumpVector = Vector3.RotateTowards(projectionVector, Vector3.up, Mathf.Deg2Rad * jumpAngleDegree, 0);
        rb.velocity = jumpVector * jumpSpeed;
    }
}

I don’t see a problem, does it play ok?

Hi Ben, yes. it works fine so far. Looks a simpler alternative to triggers at least on flat terrains.

Privacy & Terms