Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2D Triangle collider?
#1
Hi there,

I'm simulating fluid in 2D mode, and I would like to make a triangle collider. Is there any way to do that? I tried the Edge Collider 2D but it seems like it doesn't work very well.

Bobby
Reply
#2
(17-07-2022, 02:55 AM)bobby Wrote: Hi there,

I'm simulating fluid in 2D mode, and I would like to make a triangle collider. Is there any way to do that? I tried the Edge Collider 2D but it seems like it doesn't work very well.

Bobby

Hi there!

Triangle colliders in 2D are not supported, see the manual:
http://obi.virtualmethodstudio.com/manua...sions.html

Quote:Add a ObiCollider component to any collider in your scene to make it work with Obi. You can add this component to SphereColliders, MeshColliders, BoxColliders... pretty much all standard Unity colliders, both 3D and 2D. The only collider types not currently supported by Obi are PolygonCollider2D and TilemapCollider2D.

The reason for this is that Unity does not expose enough information about those kind of colliders to be able to replicate them on another engine, such as Obi.

Quote:I tried the Edge Collider 2D but it seems like it doesn't work very well.

If you're moving the collider around by setting its transform position, you will likely run into tunneling issues (fluid passing trough the collider) since edges are just lines, they have zero volume. For a static collider or a non-kinematic rigidbody it should work much better since continuous collision detection can do its job.

let me know if I can be of further help,
Reply
#3
Hey thanks for your response.

Im generating the edge colliders whenever player modifies the playing area like in this game:

[Image: TSvVpt1Rvo0Zin-400-300.jpg]

But it seems that all the collider boundaries are at a 90 degree angle, even if it has a triangle shape. I tried running obiCollider.UpdateIfNeeded() also, but it didn't help

I do notice a bit of tunneling but I don't mind that.

Also, I've tried manually dragging around the edge collider points via the editor, and the fluid doesn't react to that at all.
Reply
#4
Hi,

Edge data isn't automatically updated every frame, since it is a costly operation: a BVH-like structure must be generated to allow for fast collision queries against the edges. To update the internal edge data, you must call UpdateEdgeData():
Code:
((ObiEdgeShapeTracker2D)obiCollider.tracker).UpdateEdgeData();

let me know if I can be of further help.
Reply
#5
Wow it is working perfectly now. thank you!
Reply
#6
(18-07-2022, 07:30 PM)bobby Wrote: Wow it is working perfectly now. thank you!

You're welcome! Sonrisa let me know if you need help.
Reply