• 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
2
Question by IonoI · Jun 22, 2015 at 03:50 AM · playerjumpcontrolsgetkeydowngetbuttondown

Jumping not allways registering fix?

Sometimes when I press spacebar the game completely ignores it. It seems to ignore my jump button once every 5-10 jumps, sometimes more than once in a row. It can happen any time, doesn't matter if i'm standing still or if I havn't jumped in a while. Building the game does't fix it. My player object(ball) has sphere collider, meshrenderer, rigidbody, and character controller if it matters.

how can I make jumping respond 100% of the time?

this is in the LateUpdate method:

             if (Physics.Raycast (playerT.position, -Vector3.up, 0.6f)) {//is grounded
                 if (Input.GetKey ("x")) {
                     rb.velocity = new Vector3 (0.0f, 0.0f, 0.0f);
                 }
     
                 jumpAllowTimer = jumpAllowTime;//can jump 0.2 sec after
             
             } else {//not grounded
                 jumpAllowTimer -= Time.deltaTime;
             }
     
             if(jumpAllowTimer >= 0)//just to make it a bit more forgiving
             {
                 if (Input.GetButtonDown ("Jump")) {
                     rb.AddForce (0.0f, jump, 0.0f);
                 }
             }
             Debug.Log (jumpAllowTimer);





Comment
Add comment · Show 9
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 nu-assets · Jun 22, 2015 at 05:58 AM 0
Share

To debug weird behaviour try making a version as simple as possible:

 bool jumpAllowed = Physics.Raycast(playerT.position, -Vector3.up, 0.6f);
 
 if (Input.GetButtonDown("Jump") && jumpAllowed) 
 {
     Debug.Log("JU$$anonymous$$PED");
     rb.AddForce (0.0f, jump, 0.0f);
 }

Try that and check if the log message shows up in the console every time you hit the jump button.

PS: check your timed jump lock jumping gets allowed even after some time in air. The statement jumpAllowTimer >= 0 will be true after some time.

avatar image KayelGee · Jun 22, 2015 at 11:22 AM 0
Share

Why are you using -Vector3.up ins$$anonymous$$d of Vecto3.down?

avatar image IonoI · Jun 22, 2015 at 05:09 PM 0
Share

I tried that but sometimes it doesn't jump and the message doesn't happen.

Also tried

         if (Input.GetButtonDown("Jump")) 
         {
             count++;
             Debug.Log("JU$$anonymous$$PED" + count);
         }


Looks like some updates the jump button doesn't trigger. It didn't update the message every time.

avatar image nu-assets · Jun 23, 2015 at 05:22 AM 1
Share

Are you sure that your keyboard is ok? $$anonymous$$aybe your spacebar is damaged. Try another key or give a try with another keyboard. Your code should really work...

avatar image ColouredCarnival · Jan 10, 2017 at 08:32 PM 0
Share

I have the same issue with my code :( I'm also using jumpAllowTime (got that from Youtube, Eteeski tutorials but the videos were deleted)

Show more comments

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

Jump Further When Key Is Held Down 1 Answer

When I Hold The Jump Button, Player Will Fly? 2 Answers

Slowing player speed when in air 1 Answer

Why when i press space button nothing was happened 0 Answers

Mulltiple jumps 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges