Reputation: 265
Currently I am working on a networked 2d platform game.
My player is an empty object which serves as a parent to my actual graphics etc. The empty object has a rigidbody (3d)
attached to it as it needs to have one in order to use the configurable joint
component ( note: I move my player around using this 3d rigid body).The player body however, a child to the graphics, has a box collider 2d
attached to it as it after all it is a 2d game and has to collide with other 2d objects.
My platforms have polygon collider 2d
s attached to them (which is connected to a platform effector if that is worth mentioning).
Now, even though both my player body (which is a child to graphics which is a child to my player object) and my platforms have 2d colliders
on them they do not collide and can simply go inside each other (neither of them is marked as isTrigger
).
In order to solve this I thought I would add a rigidbody 2D
to the player body and see if that would do anything. Now upon adding the rigidbody 2D
collisions did work but as soon as I made the rigidbody 2D
have all position and rotation constraints ticked or as soon as I made it kinematic
or static
it would cease to collide with my platforms. The problem is I need to have the rigidbody 2D
be static
or not be able to move as I am currently moving my player object using the rigidbody (3d)
attached to it and do not want any additional movement of the player body upon colliding with objects.
I know this is quite a lot of information, so if you have any questions or would like further information just comment and I will be quick to respond. Thank you :-)!
Edit:
2d ray casts are also unable to hit the player body box collider 2D
Edit 2: So to recap:
If either the player body or the platform has a rigidbody 2d
that is not static (dynamic) and can move collisions work. However currently I only have a rigidbody 2D
on my player body which has to be static though (as explained earlier) as well as a box collider 2d
. My platform(s) on the other hand currently only has a polygon collider 2d
as I do not see why it would need a rigidbody 2D
.
Upvotes: 1
Views: 6112
Reputation: 1256
Rigidbody2D can't collide with Rigidbody3D, here's a workaround though
http://answers.unity3d.com/questions/580769/can-rigidbody-2d-collide-with-3d-colliders.html
Upvotes: 0
Reputation: 2612
A static collider won't detect the collision with another collider if it doesn't have a rigidbody, if it is static or if it has a kinematic rigidbody. At least one of your two objects needs to not be static and to have a rigidbody which is not kinematic to be correctly detected. So you do need to add a Rigidbody2D to your platform.
When you have a doubt about why a collider wouldn't collide with another one, always refer to this page of Unity's documentation which sums up which kind of collider will collide with another one.
Upvotes: 2