Forum rules - please read before posting.

Jump Cooldown

Hi

Is there a way to have a cooldown on jump button pressed. Currently we can spam the jump button and causing animation to not play cause the previous jump animation has not complete

Comments

  • If you want the Player to be able to jump while LandSoft is playing, you can create a Transition from LandSoft to Jump that uses the same conditions as that from Locomotion to Jump.

    If you want to prevent the Player from being able to jump until a certain time has passed after they land (a duration that e.g. matches the length of the LandSoft animation), you can attach a custom script to the Player:

    using UnityEngine;
    using AC;
    
    public class LimitJumping : MonoBehaviour
    {
    
        public float jumpLandDelay = 1f;
        private float jumpTimer;
    
    
        private void Update ()
        {
            if (KickStarter.player.IsJumping)
            {
                if (jumpTimer < jumpLandDelay)
                {
                    jumpTimer = jumpLandDelay;
                    KickStarter.player.jumpingLocked = true;
                }
            }
            else
            {
                if (jumpTimer > 0f)
                {
                    jumpTimer -= Time.deltaTime;
    
                    if (jumpTimer < 0f)
                    {
                        jumpTimer = 0f;
                        KickStarter.player.jumpingLocked = false;
                    }
                }
            }
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.