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 /
  • Help Room /
avatar image
0
Question by Manyula · Jul 03, 2017 at 12:18 PM · movementcharactercontrollerjump

Grounded and pressing "jump" not working?

I'm trying to make my character jump. I want to do this by checking that the character controller is grounded, and that the jump button has been pressed. Individually, these work correctly if(controller.isGrounded) and if(Jump button pressed)), but together they don't.` Why not? If they are both true on their own, why aren't they true one after the other?

EDIT: I've figured out what the main problem was: it was the fact that my character wasn't moving along his yVelocity at all so I guess it couldn't tell if it was grounded. However a new problem has arisen. Even when the method itself is invoked (that is, when the jump button is pressed and the character is on the ground) the Y Velocity doesn't change. So the method is called but for some reason it won't make the character jump? I'd say it's about 60% of the time the character jumps and 40% it just ignores it.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Major · Jul 03, 2017 at 03:59 PM

In my experience with the CC, it has poor ground detection. The best way I can put it is that it "flickers" true/false very quickly. Without seeing more code and understanding exactly how everything works, I would say that you might need to set a vertical velocity when grounded (something small like Time.deltaTime has worked fine in my experiments), and calling CC.Move () to apply said velocity. I hope that helps, again it's hard to address the question without seeing application.

Comment
Add comment · Show 2 · 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
avatar image Manyula · Jul 06, 2017 at 01:29 PM 0
Share

That's unfortunate. The strange thing is that it was working when I first implemented the jump mechanic; it would call the Jump() method every frame and check the two if statements one after the other, but now it seems to be ignoring them.

Currently my character's vertical velocity is set to -gravity if grounded and if not is set to -= gravity. Do you think this might be casing an issue? Again it seemed to work fine before.

EDIT: I've figured out what the main problem was: it was the fact that my character wasn't moving along his yVelocity at all so I guess it couldn't tell if it was grounded. However a new problem has arisen. Even when the method itself is invoked (that is, when the jump button is pressed and the character is on the ground) the Y Velocity doesn't change. So the method is called but for some reason it won't make the character jump?

avatar image Major Manyula · Jul 15, 2017 at 08:05 PM 0
Share

I really wish I got emails for these things...

I'm sorry I didn't see this. You should probably check to make sure that the y-velocity is being set in a continuous function like update or fixed update.

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

141 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

Related Questions

Using Velocity breaks my jumping 0 Answers

Double Jump using character controller 0 Answers

Problem with Jump script 1 Answer

Jump logic issues 0 Answers

Basic MOVE and JUMP script (Jump trouble) 2 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