x


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

more ▼

asked Dec 09 '09 at 06:35 AM

Papa Stanley gravatar image

Papa Stanley
13 1 1 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Dec 09 '09 at 07:06 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

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 RTFM 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. YMMV but worked for me.

thanks for your help Jaap, and timely reply

.:S:.

Dec 10 '09 at 06:18 AM Papa Stanley
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2488
x1866
x1469

asked: Dec 09 '09 at 06:35 AM

Seen: 7247 times

Last Updated: Dec 09 '09 at 06:35 AM