- Home /
Terrain and rigidbody not colliding - boat versus bank
Hi Unitarians,
I have a terrain and a rigidbody modelling a boat and a riverbank. The terrain has the standard collider, and the boat has a rigidbody with kinematic set, as the movement is controlled via script, not the physics engine.
The problem is the boat will simply sail through the terrain I have generated, when I want it to crash. I have tried swapping the terrain collider for a rigidbody collider, and also adding a character controller into the boat, in addition to the rigidbody. Nothing works.
The boat is limited to one plane of movement, and it will intersect a water plane as well for the illusion of flotation.
Do I need to somehow turn on collisions? I thought this was handled automagically by the physics colliders? Is kinematic the problem?
if I turn off kinematic, and turn on gravity the boat falls. It is above the base plane of the terrain mesh BTW. What gives?
Thanks in anticipation
Papa
Answer by Jaap Kreijkamp · Dec 09, 2009 at 07:06 AM
First, you either need to add a collider or a CharacterController to get collisions. Best in your case is CharacterController, otherwise you need physics with kinematic OFF. If you have a charactercontroller added you can remove the rigidbody and all other colliders. Move the object using the Move methods in the charactercontroller instead directly on Transform. You can still rotate the normal way. The collisionflags of the charactercontroller can be used to determine collisions.
thanks mate, that seemed to do the trick - once I mucked around with a fresh controller and terrain using the CC movement example from the reference, then I started porting my movement script over without much drama. Should have RTF$$anonymous$$ I know ;-)
For others who have to do this - most changes simply involved adding the controller object before the original rigidbody transform.Rotate calls, eg transform.Rotate(Vector3(blah... becomes controller.transform.Rotate(Vector3(blah... where controller is the instance of the CC. Y$$anonymous$$$$anonymous$$V but worked for me.
thanks for your help Jaap, and timely reply
.:S:.
Your answer
Follow this Question
Related Questions
Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer
Raycast to Terrain (Conditional Statements) 1 Answer
Terrain collider is inaccurate 3 Answers
A.I. units partially sinking in to the terrain, on just one location 0 Answers
Irregular ground collision 1 Answer