Posts: 5
Threads: 3
Joined: Jun 2017
Reputation:
0
Obi Owner:
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.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(26-06-2017, 05:12 PM)herbst Wrote: 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.
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!
Posts: 5
Threads: 3
Joined: Jun 2017
Reputation:
0
Obi Owner:
I see, so the Script Execution Order was the magic thing. I suggest you mention that somewhere in the docs
Thanks!
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(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
Thanks!
We are planning to add a simpler API for forces, so in the near future script execution order won´t matter.
Posts: 13
Threads: 8
Joined: Aug 2017
Reputation:
0
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?
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(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.
Posts: 13
Threads: 8
Joined: Aug 2017
Reputation:
0
16-11-2018, 09:09 PM
(This post was last modified: 16-11-2018, 09:10 PM by p3gamer.)
(02-11-2018, 07:27 PM)josemendez Wrote: 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.
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.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(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.
|