Hi All,
That's the basic question, But if anyone has teh inclination to read teh background.. here it is..
My starting point is the 3rd person controller from 3dbuzz tutorials, with a lot of my own enhancements.. I had added a feature for the character to "use" a vehice "vehicles" (Horse, flying bird etc..) which are parented to the character. But as i couldn't expand my character controller to cover the "Vehicle", and i can't put a full rigidbody on it, they keep slicing into objects.
After a lot of trials and errors, I finally have one solution working to my satisfaction.. I made an "Extended Char Controller) by creating a ghost object - a cube resized to match the vehicle (and parented to it), and collider component removed and rendering turned off. Then whenever i move, or rotate, or fall, I first do that t o my ghost component, and then use Overlapsphere to find objects close by, and then use MeshRenderer.bounds.Intersects() to see if it is OK to process that action.
Earlier i tried with raycasts, but for it to be accurate I need to do at least 5 raycasts in teh direction (from 4 corners and centre) and check normals to make sure i don't slice into sharp edges.. I just want to know, for academic interests, and to see if it can optimize performance. How teh overlapsphere compares with raycasts. I know it uses raycasts internally.. (I put teh "Floor" and "Player" into "Ignore Raycasts" layer and they don't turn up in the overlapsphere colliders list..)
Edit: One more info.. I don't do this on update.. Only when a key is pressed...
Thanks & Regards
Rajesh
↧