Best way to check if touching to the ground?
Posted: Mon Jul 03, 2017 9:03 pm
I am using just a box rigidbody to fake the whole locomotion. It is very basic and I am not raycasting for the wheels.
The faked locomotion is good enough for my purpose.
My problem is not to drive it while it is not on the ground.
If I just raycast from the center, it does not work on the ramps (which makes perfect sense as the right and left edge will be touching to the ground where as the center is in the air).
So, I was thinking about raycasting 4 lines from 4 bottom corners of the rigidbody in the -Y axis direction + center. So if at least 1 of them hits, that means it is grounded.
On the other hand, I am also thinking about using convexTest?
Which one would be better for the performance? Just shape casting looks like the perfect solution but I would be glad if you share your experience with me.
The faked locomotion is good enough for my purpose.
My problem is not to drive it while it is not on the ground.
If I just raycast from the center, it does not work on the ramps (which makes perfect sense as the right and left edge will be touching to the ground where as the center is in the air).
So, I was thinking about raycasting 4 lines from 4 bottom corners of the rigidbody in the -Y axis direction + center. So if at least 1 of them hits, that means it is grounded.
On the other hand, I am also thinking about using convexTest?
Which one would be better for the performance? Just shape casting looks like the perfect solution but I would be glad if you share your experience with me.