Posts: 4
Threads: 1
Joined: Jan 2018
Reputation:
0
Obi Owner:
Hello,
I'm new to Obi Fluid and in the process of getting familiar with it.
I'm trying to have a very simple 2D scene, similar to 'Simple Fluid' in the Sample Scene folder.
I start a new scene, add an Obi Emitter (with solver), and turn it 90 degrees on the x-axis so it emits downward.
I then add an empty Game Object, and add 'Rigidbody 2D', 'Box Collider 2D' and 'Obi Collider 2D (Script)' to that object. As per the instructions, I make sure the emitter and game object are in different layers.
When I run the scene, two unexpected things happen:
1. The Obi particles 'enter' the object, i.e. they don't bounce off the surface, some of them even 'fall through' the object.
2. When I switch to 3D view, and have a look from the side, I can see the particles are not remaining in the 2D plane (z=0), i.e. they move backwards and/or forward once they hit the object.
Eventually I would like to create a simple bucket and fill it with fluid in 2D. How do I best go about this, so the fluid stays a) in the 2D plane, and b) in the bucket. Also, is there an easy way to fill the bucket when the scene gets executed, i.e. without having to 'emit' the fluid into it first, which takes a while?
Thank you!
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(03-01-2018, 08:26 AM)hmhmhm Wrote: Hello,
I'm new to Obi Fluid and in the process of getting familiar with it.
I'm trying to have a very simple 2D scene, similar to 'Simple Fluid' in the Sample Scene folder.
I start a new scene, add an Obi Emitter (with solver), and turn it 90 degrees on the x-axis so it emits downward.
I then add an empty Game Object, and add 'Rigidbody 2D', 'Box Collider 2D' and 'Obi Collider 2D (Script)' to that object. As per the instructions, I make sure the emitter and game object are in different layers.
When I run the scene, two unexpected things happen:
1. The Obi particles 'enter' the object, i.e. they don't bounce off the surface, some of them even 'fall through' the object.
2. When I switch to 3D view, and have a look from the side, I can see the particles are not remaining in the 2D plane (z=0), i.e. they move backwards and/or forward once they hit the object.
Eventually I would like to create a simple bucket and fill it with fluid in 2D. How do I best go about this, so the fluid stays a) in the 2D plane, and b) in the bucket. Also, is there an easy way to fill the bucket when the scene gets executed, i.e. without having to 'emit' the fluid into it first, which takes a while?
Thank you!
Hi,
Regarding collisions, you need to set the collider and the emitter in different phases, not layer (as stated in the docs: http://obi.virtualmethodstudio.com/tutor...sions.html). As long as the collider is in one of the layers selected for collisions by the ObiSolver (the default layer is one of them), you do not need to tinker with layers. In your case, the solution would be to either set the emitter's phase to 1, or the collider's phase to 1.
To create 2D fluid, you need to enable 2D mode in your ObiSolver component. (ObiSolver->Parameters->Mode: 2D). If you don't, fluid will be simulated in 3D space by default. Mixing 2D colliders with 3D simulation will cause the colliders to be regarded as thin sheets, and collisions will be easily missed.
To fill an area with fluid, you can use the ObiEmitterShapeSquare component instead of the default disk shape. First remove the ObiEmitterShapeDisk component, add ObiEmitterShapeSquare and set the amount of particles to be that of the amount of distribution points in the shape.
Note that you can also create your own emission shapes by extending the ObiEmitterShape class, in case the included ones (rectangles, disks, etc) are not enough for your purpose.
cheers!
Posts: 4
Threads: 1
Joined: Jan 2018
Reputation:
0
Obi Owner:
Thank you Jose, for the quick and detailed reply. I had indeed not set the Mode to 2D. That immediately removed the problem of the particles leaving the 2D plane. I then checked the phases and they were 1 for the emitter and 0 for the game object by default. So all I did was change the mode to 2D, but that still leaves me with the problem of particles entering the object:
This what the inspector looks like for the emitter:
Is there anything else I am doing wrong?
Thank you for the hint regarding 'extending the ObiEmitterShape class'. Is there a tutorial or an example of this available for me to look at? I'm aiming for a triangle shape.
Once again thank you!
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
04-01-2018, 07:25 PM
(This post was last modified: 04-01-2018, 07:26 PM by josemendez.)
(04-01-2018, 12:43 PM)hmhmhm Wrote: Thank you Jose, for the quick and detailed reply. I had indeed not set the Mode to 2D. That immediately removed the problem of the particles leaving the 2D plane. I then checked the phases and they were 1 for the emitter and 0 for the game object by default. So all I did was change the mode to 2D, but that still leaves me with the problem of particles entering the object:
This what the inspector looks like for the emitter:
Is there anything else I am doing wrong?
Thank you for the hint regarding 'extending the ObiEmitterShape class'. Is there a tutorial or an example of this available for me to look at? I'm aiming for a triangle shape.
Once again thank you!
Hi!
Your emitter scale is negative. That means it is turned "inside out", so particles will collide with its inner walls. Set the Y scale to 0.1 instead and it will work as you expect.
Extending classes is a basic C# skill, so I assume you already know how to do that. The details on what to do when extending it are:
-Set samplingMethod to FILL in the Awake() method.
-Override the two abstract methods of the base class ( SupportsAllSamplingMethods() and GenerateDistribution()).
-SupportsAllSamplingMethods should return false.
-In GenerateDistribution, simply fill the distribution List<> with distribution points. These are the places in the shape where the particles will spawn. Each point has a position and a velocity. You probably want their positions to resemble a triangle
All included emitter shapes (ObiEmitterShapeDisk, ObiEmitterShapeCube, ObiEmitterShapeEdge, etc) extend from ObiEmitterShape, so you can look at them as examples.
cheers
Posts: 4
Threads: 1
Joined: Jan 2018
Reputation:
0
Obi Owner:
Once again thank you. I didn't even realize that I had a negative figure there. Now it all works perfectly. This is for a maiden Unity/C# project, so your details on what to do when extending the class are invaluable and will save me (and anyone else reading this and in the same situation as me) many hours of researching and trial and error. Once again thank you for taking the time!
Posts: 4
Threads: 1
Joined: Jan 2018
Reputation:
0
Obi Owner:
Hi Jose,
I just went over the tutorial pages again, to see how I could get the layer/phases and 2D/3D part wrong. Hopefully I can 'repay' for your fantastic support, by helping to improve the tutorial pages:
1. FAQ, I set up colliders as explained in the manual, but I can´t get Obi objects to collide with them. Is this a bug?
Most likely the cause is that your colliders and your Obi actors (cloth, rope, etc.) are in the same layer. Obi requires actors and colliders to be in separate layers in order to generate contacts, as this allows for more fine-grained collision control. See the collisions manual page for detailed info.
-> I believe this should read:
Most likely the cause is that your colliders and your Obi actors (cloth, rope, etc.) are in the same phases. Obi requires actors and colliders to be in separate phases in order to generate contacts, as this allows for more fine-grained collision control. See the collisions manual page for detailed info.
2. Introduction/Obi Solver
-> When explaining all the parameters, 'Mode' is being omitted, i.e. the explanation goes from 'Collider Group' straight to 'Interpolation', without making mention of mode, which sits in between.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(07-01-2018, 12:39 AM)hmhmhm Wrote: Hi Jose,
I just went over the tutorial pages again, to see how I could get the layer/phases and 2D/3D part wrong. Hopefully I can 'repay' for your fantastic support, by helping to improve the tutorial pages:
1. FAQ, I set up colliders as explained in the manual, but I can´t get Obi objects to collide with them. Is this a bug?
Most likely the cause is that your colliders and your Obi actors (cloth, rope, etc.) are in the same layer. Obi requires actors and colliders to be in separate layers in order to generate contacts, as this allows for more fine-grained collision control. See the collisions manual page for detailed info.
-> I believe this should read:
Most likely the cause is that your colliders and your Obi actors (cloth, rope, etc.) are in the same phases. Obi requires actors and colliders to be in separate phases in order to generate contacts, as this allows for more fine-grained collision control. See the collisions manual page for detailed info.
2. Introduction/Obi Solver
-> When explaining all the parameters, 'Mode' is being omitted, i.e. the explanation goes from 'Collider Group' straight to 'Interpolation', without making mention of mode, which sits in between.
Hi,
Thanks a lot for bringing this to my attention! we've updated the documentation to fix these issues (and a few others). Your help in discovering these omissions/inaccuracies is invaluable!
|