Adding custom particle forces - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: General (https://obi.virtualmethodstudio.com/forum/forum-5.html) +--- Thread: Adding custom particle forces (/thread-16.html) |
Adding custom particle forces - herbst - 26-06-2017 Hey there, I'm sure I'm overlooking something simple here. I'm trying to apply custom forces to particles. So what I did is basically duplicate the ObiSphericalForceZone, since it contains the relevant calls to Oni.AddParticleExternalForces. However, no matter what I do, this custom script does not apply any forces to the particles. Is there some magic thing I have to do to make Obi use these custom forces? Otherwise, I have to put the code directly into the SphericalForceZone or AmbientForceZone, which I'd like to avoid since I am using both already. RE: Adding custom particle forces - josemendez - 27-06-2017 (26-06-2017, 05:12 PM)herbst Wrote: Hey there, I'm sure I'm overlooking something simple here. You have to apply forces at the correct time. Do it in LateUpdate(), and ensure your script execution order is set after the solver's (Edit->Project settings->Script execution order). This is what the force zone classes (spherical and ambient) do. The reason for this is that the solver clears up force buffers at the end of each frame, so you want to insert forces for the next frame right after this happens. cheers! RE: Adding custom particle forces - herbst - 27-06-2017 I see, so the Script Execution Order was the magic thing. I suggest you mention that somewhere in the docs Thanks! RE: Adding custom particle forces - josemendez - 29-06-2017 (27-06-2017, 01:28 PM)herbst Wrote: I see, so the Script Execution Order was the magic thing. I suggest you mention that somewhere in the docs We are planning to add a simpler API for forces, so in the near future script execution order won´t matter. RE: Adding custom particle forces - p3gamer - 02-11-2018 I'm trying to accomplish the same thing but only apply the external force on a button click. I am using an ObiSphericalForceZone (in 2D if that matters). I've duplicated the SimpleFluid and set the atmospheric drag > 0. I've played around with the intensity and turbulence parameters, but I am not seeing any forces being applied ( I even moved the ApplyForcesToActor( ) into the LateUpdate( ) ). Is there an example that uses ObiSphericalForceZone? RE: Adding custom particle forces - josemendez - 02-11-2018 (02-11-2018, 04:16 PM)p3gamer Wrote: I'm trying to accomplish the same thing but only apply the external force on a button click. I am using an ObiSphericalForceZone (in 2D if that matters). I've duplicated the SimpleFluid and set the atmospheric drag > 0. I've played around with the intensity and turbulence parameters, but I am not seeing any forces being applied ( I even moved the ApplyForcesToActor( ) into the LateUpdate( ) ). Is there an example that uses ObiSphericalForceZone? Hi, Doing exactly what you describe, works fine for me. If the force zone is not in radial mode, make sure the wind is not blowing into/away from the screen in the Z axis (as that would have no effect in 2D). You can rotate it to make sure the wind direction arrow points in the right direction. RE: Adding custom particle forces - p3gamer - 16-11-2018 (02-11-2018, 07:27 PM)josemendez Wrote: Hi, So I think misunderstood what ObiSphericalForceZone is used for. If I'm not mistaken, both ObiAmbientForceZone and ObiSphericalForceZone are used for wind simulations, correct? If that's the case, what I should be using is this: Oni.AddParticleExternalForce(solver.OniSolver, ref force, particleIndices, particleIndices.Length) since I am not using wind. RE: Adding custom particle forces - josemendez - 17-11-2018 (16-11-2018, 09:09 PM)p3gamer Wrote: So I think misunderstood what ObiSphericalForceZone is used for. If I'm not mistaken, both ObiAmbientForceZone and ObiSphericalForceZone are used for wind simulations, correct? If that's the case, what I should be using is this: Oni.AddParticleExternalForce(solver.OniSolver, ref force, particleIndices, particleIndices.Length) since I am not using wind. Depending on which actor you're using, force zones affect them differently. For instance, cloth and fluids are affected by a force zone as a wind source. Ropes are affected by them as forces, since they have no surface for the wind to act upon. However, using One.AddParticleExternalForce guarantees you add forces, not wind. |