- Home /
Does the physics engine have an accessible 'grounded' variable?
Hi, In the course of making a 2D platformer using rigidbodies/physics, I'm faking the movement to be more kinematic-like under certain conditions to get a more 'cartoony' movement. To do this I need a 'grounded' boolean which I can get a couple of different ways (e.g raycasting, checking velocity.y etc.). But this got me thinking... wouldn't the physics engine need to keep a similar variable internally?... and if so is there any way to access this, to improve on efficiency?
Thanks
Answer by SrBilyon · Aug 24, 2011 at 08:39 AM
The only grounded variable I know of exists for character controllers. CharacterController.isGrounded is the boolean you would use.
If you want to go the raycasting route, this might help: http://answers.unity3d.com/questions/11288/raycast-collision-not-behaving-as-expected.html
Thanks, I guess that's the case. Thanks for the link... some useful ideas there. :)
Answer by Waz · Aug 24, 2011 at 10:57 AM
The concept you're describing is, in the more general case of the physics engine, the set of contact points, be they ground, things sitting upon them, or fulcrums upon which they are teetering.
It seems not so easy to maintain that set of contact points.
But certainly they are in there: a count of them, including sleepers, is even visible in the Profiler.
Interesting, just looked in the profiler and there they are, However, as you say in your other post, info about contact points is pretty elusive. Did you ever go as far as getting the Physx docs?
I found a specific solution to the specific problem I had at the time, and haven't needed to try again. I hope it'll get answered eventually, since a few people have asked for things that it would solve. If I ever need it again, I'll try harder next time.
Your answer
![](https://koobas.hobune.stream/wayback/20220612191029im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make rigidbody character stay on ground 2 Answers
Problem with Colliders 1 Answer
Drag & Drop GameObject with MovePosition shoots other Gameobject away in case of them colliding 1 Answer
Enemy can't trigger a hit when the player doesn't move 0 Answers
Make a rolling ball always on ground without falling when reaching the edges of the map 1 Answer