I have some objects which are 3d objects, but I want to limit the physics on them to 2D.
So do I have to write a physics system from scratch, or is there a way to limit the physics to 2D?
Also I want to use the built in collision system, but I also want to test if objects without rigid bodies intersect with each other, is there a test colliders function, that would test if two colliders are currently overlapping?
You should be able to use the existing physics system. One way I’ve seen it done is to apply joints that constrain the objects to a single plane; another is to ‘clamp’ the position and rotation manually on each update.
I think there’s a side-scroller tutorial that touches on this, and the ‘Evac City’ tutorial covers this as well.
I think that he needs a physics system thats only the X and Y axis, so that when physics kick in, his objects arent falling of the platform in the Z axis. thats my best guess…you should be able to do it by using a configurable joint. if not, check the wiki, they usually got some pretty cool scripts over there.
In the simplest case I can think of, I have a sphere collider and a box collider, neither are rigid bodies.
I want to be able to move the sphere, and know on what frames it intersects with the cube.
I thought there’d be something like:
colliderA.Test(colliderB)
or
Collider.Test(colliderA,colliderB);
The actual use is a 2d tight rope, through which collider meshes can’t move in my 2d plane, but they can bend it. So I want to know when it hits and where and then to subdivide the rope into smaller parts to make it flex and in the worse case it can snap and end up wrapped around a collider several times.
The problem is I want a test for intersection not collision, as neither has necessarily moved.
I’m also slightly worried about the cpu time requirement to use joints to lock everything to my plane, especially if there are lots of items and it’s on an iphone.
I can’t say for sure, but you might be able to achieve what you want by using kinematic rigid bodies, possibly set as triggers. (If you haven’t already seen it, see this page for info on which object type pairs will generate collision messages.)
You might also be able to use the ‘sphere overlap’ test to determine if any intersections have occurred (although this will only test bounding volumes, not the actual shapes).
As for your question though, I don’t know that the Unity API exposes any functions like the ones you mentioned.