Hey there,
I need to calculate 3D collisions between a sprite moving in 3D space at a fixed “height” (z
axis) and the 3D environment around it (which has its own mesh colliders, concave). I’ve given this sprite a 2D collider for several reasons and I don’t want to change it to a 3D collider.
I wanted to create a 2D collision by detecting the ContactPoints
between a plane mesh (3D collider) following my sprite and the environment collisions around. Problem is, the OnCollisionEnter
/_Stay
/_Exit
methods will only work if one of the two colliders has a non-kinematic Rigidbody
(for performance’s sake, it HAS to be the plane’s collider), but at the same time a non-convex (concave) collider WON’T work with a non-kinematic Rigidbody
.
Which means, the only way to use the Plane Mesh
as a collider would be to make it concave, issue being that it stops being a plane and it becomes a cube. I can nudge the plane position so that one of the edges matches the Z
axis of the sprite (and thus the Z
axis of where I want the contact Points to be calculated) but it’s… Messy. It’s a “duct-tape” kind of solution I don’t like.
I’ve tried using a Sphere collider and trying to use only the contactpoints
that occur at that Z
coordinates, but it doesn’t seem to work. I think it’s because the ContactPoints
only work with the very first part of the sphere that collide with the 3D environment, and that is almost always at a different Z
height.