Collider for controllable ship

Hello,

I have the following Problem:

I’ve build a ship in Blender and imported that into Unity to start developing my game.
There’s already water, a character, a steering (driving) mechanism and some islands…
My character can walk on the ship and he can enter drive mode by pressing f.
This is working properly, but when I am driving into Islands the ship just doesnt stop and moves through them…I’ve already tried out every single combination of colliders and rigidbodies and am a little bit frustrated right now :smile:
I just want the ship to stop when colliding with the islands can somebody help me?
Do I have to manage that in my scripts?
And another question when I put rigidbodies onto my ship-object the character just falls through the ship, but when I add these to every single sub-object of the ship it works…
Thanks in advance and sorry for my english ^^

The rigid body for your ship is likely trying to wrap around the mesh, and since you said it’s mostly subobjects, it doesn’t really have much mesh to collide with.

How are you handling the collision? Is the collider or trigger callback being called?

1 Like

and how are you doing the ship movements? are you adding force or are you doing transform.position. transform.position ignores colliders.

1 Like

I have these two :

rbody.AddTorque (0f, h * turnSpeed * Time.deltaTime, 0f);
rbody.AddForce(transform.forward*v*accellerateSpeed*Time.deltaTime);

And I am not handling the collision…I thought adding a collider and rigidbody would be enough^^

My ship is too complex for using a convex mesh collider…
Also using the primitive colliders is hard cause they are not detailed enough and people still need to walk properly on the ship while someone is driving (btw. by using just a box collider the ship collided)…
Or can you disable colliders for the players? Then People could still walk on it and the primitive colliders prevent my ship from driving into Islands…

yep, you can create layers, and have the player ignore the ship collider layer.

1 Like

Nice thank you I think that will be the solution:smile::smile::smile:

Just in case you wanna know what I did now…
I put few primitive colliders around my ship (layer ship).
Then I changed the layer of the Islands to “Islands”.
The Player got the layer “Player”.

Then I adjusted under: Edit → Project Settings → Physics, the Matrix of layers so that for example the ship layer is ignored by the Player layer etc…
Remind: All subobjects of the ship still are layer “Default”, only the upper object has These colliders in layer ship.

Finally cause my colliders didnt rotate with the ship I just had to implement this:

collider.transform.RotateAround(transform.position, new Vector3(0,1,0), h);

Thank you for your help!