Obi Official Forum
2D Triangle collider? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: 2D Triangle collider? (/thread-3525.html)



2D Triangle collider? - bobby - 17-07-2022

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


RE: 2D Triangle collider? - josemendez - 18-07-2022

(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/manual/6.3/collisions.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,


RE: 2D Triangle collider? - bobby - 18-07-2022

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.


RE: 2D Triangle collider? - josemendez - 18-07-2022

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.


RE: 2D Triangle collider? - bobby - 18-07-2022

Wow it is working perfectly now. thank you!


RE: 2D Triangle collider? - josemendez - 19-07-2022

(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.