Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ItArth · Jan 17, 2020 at 11:02 PM · scripting problemjump

Make a Jump Delay

How i can make a jump delay in this script?

         private void Update()
         {
             if (!m_MouseLook.mIsPaused)
                 Crouching = inputManager.GetButtonDown("Crouch");
             anim.SetBool("crouch", Crouch);
 
             RotateView();
             // the jump state needs to read here to make sure it is not missed
             if (!m_Jump && !m_onLadder)
             {
                 if(!m_MouseLook.mIsPaused)
                 m_Jump = inputManager.GetButtonDown("Jump");
             }
 
             if (!m_PreviouslyGrounded && m_CharacterController.isGrounded && !m_onLadder)
             {
                 m_MoveDir.y = 0f;
                 m_Jumping = false;
             }
             if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
             {
                 m_MoveDir.y = 0f;
             }
 
             if (isSwimming && inputManager.GetButton("Jump"))
                 m_MoveDir.y = 2.5f;    
 
             m_PreviouslyGrounded = m_CharacterController.isGrounded;
 
             if (m_onLadder)
             {
                 StopAllCoroutines();
                 rigidbody.useGravity = false;
                 rigidbody.isKinematic = true;
                 LadderUpdate();
             }
             else
             {
                 LadderObject = null;
                 rigidbody.useGravity = true;
                 rigidbody.isKinematic = true;
             }
         }
 
         private void FixedUpdate()
         {
             float speed;
 
             GetInput(out speed);
             
             if (!m_onLadder)
             {
                 // always move along the camera forward as it is the direction that it being aimed at
                 Vector3 desiredMove = transform.forward * m_Input.y + transform.right * m_Input.x;
 
                 // get a normal for the surface that is being touched to move along it
                 RaycastHit hitInfo;
                 Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
                                    m_CharacterController.height / 2f);
                 desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;
 
                 m_MoveDir.x = desiredMove.x * speed;
                 m_MoveDir.z = desiredMove.z * speed;
 
 
                 if (m_CharacterController.isGrounded)
                 {
                     if (Crouching)
                         OnCrouch();
 
                     m_MoveDir.y = -Stats.m_StickToGroundForce;
 
                     if (m_Jump)
                     {
                         rigidbody.velocity = new Vector3(0,0,0);
 
                         if (Crouch)
                             OnCrouch();
 
                         else
                         {
                             m_MoveDir.y = Stats.m_JumpSpeed;
                             m_Jump = false;
                             m_Jumping = true;
                         }
                     }
                 }
                 else
                 {
                     if (Crouch)
                         OnCrouch();
 
                     m_MoveDir += Physics.gravity * Stats.m_GravityMultiplier * Time.fixedDeltaTime;
                 }
                 m_CollisionFlags = m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime);
             }
 
             if (Crouch &&!isSwimming)
             {
                 Stats = CrouchStats;
             }
             else
             {
                 Stats = saveStats;
             }
         }

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fariborzzn · Jan 17, 2020 at 11:47 PM 0
Share

take look at: https://answers.unity.com/questions/1691253/delay-for-jump-with-the-default-fps.html?childToView=1691259#answer-1691259

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by logicandchaos · Jan 18, 2020 at 02:30 AM

do you mean like a delay between jumps? when I need to make little delays I use Invoke() bool canJump=true; float jumpDelay=1.0f;

 public void Jump()
 {
 if(!canJump)
 return;
 //your code here
 canJump=false;
 Invoke("ResetJump",jumpDelay);
 }
 
 public void ResetJump()
 {
 canJump=true;
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

213 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why can't my character jump 2 Answers

Player cannot jump if not in update or fixed update 2 Answers

I really need a JumpPad script for a JumpPad in unity 2D 0 Answers

Im doing a 3d endless runner, but i just cant get my cube(player) to jump when i press the spacebar, ive searced everywhere and tried a lot of different jump scripts but to no avail. 0 Answers

Shotgun Jump/ Rocket Jump with character controller 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges