Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 shkc0328 · Mar 12, 2015 at 02:42 PM · triggercharactercontrollergravityisgrounded

How reliable are isGrounded checks?

Do they sometimes randomly trigger off when the player moves?

How does the standard asset "CharacterMotor" apply gravity to the player?

Comment
Add comment · Show 3
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 AlwaysSunny · Mar 12, 2015 at 04:05 AM 0
Share

Generally, no. The physics sim is industry-proven. But solving edge cases is part of writing strong controllers, so there's no harm in preparing for that eventually.

avatar image shkc0328 · Mar 12, 2015 at 10:29 PM 0
Share

Do you mean that is isn't reliable or that it doesn't trigger off? Judging by your "industry-proven", I'm guessing that it is very reliable.

avatar image AlwaysSunny · Mar 12, 2015 at 11:05 PM 0
Share

Correct, Unity uses PhysX, one of the (3? 4?) major competing physics engines in the world of realtime graphics. I won't say it never behaves unpredictably, but you can and will learn its weak areas, quirks, and limitations over time. None are insurmountable, if your expectations are reasonable.

Still, much of my code which polls for physics information includes some kind of failsafe for instances where the expected behavior deviates from the norm. This is just a good practice, and you'll come to know when it's necessary. For an isGrounded check, I sort of throw caution to the wind and trust it. I'd say it's exceptionally reliable, especially when used in conjunction with well-designed collision meshes and carefully orchestrated situations.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by flannel40000 · Mar 18, 2015 at 01:07 PM

I found it not to be reliable as I am using a mechicam animation system for a third person shooter and opted towards a character controller for my player rather than a rigidbody after much trial and error with that. I found that my CharacterController.isGrounded did not update after it was marked true as i always start my characters in the air, so I made my own isgrounded application and here is the code for it.

 private Vector3 grav;
 private  CollisionFlags collisionFlags;
 private float gravity = 9.8f;
     
 void Update () {
     if (IsGrounded()) {
     grav.y += -gravity * Time.deltaTime;
     cc.Move (grav * Time.deltaTime);
     } else {
     grav = new Vector3(0,0,0);
     }
 }
 
 public bool IsGrounded () {
     return (CollisionFlags.CollidedBelow) != 0;
 }

It is a bit jittery with my character going up and down hills but that requires some smoothing out which I haven't gotten to yet as I made this script today. Bonus points for not using a RayCast system? Hope it helps :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

CharacterController isGrounded toggles value 2 Answers

Adding gravity to character and grounded checks are not working? 0 Answers

controller.Move doesn't stay grounded when walking down slope 3 Answers

Why does my characterController code not apply gravity correctly? 0 Answers

Jumping Stopped Working. 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