I’m looking at force fields here. How can I make an oscillating force field? Like an object that goes up and down with a certain amplitude and frequency, a sort of noise force field that is not random.
Hi Federico,
Attached is a USDA file that contains a Spherical Force Field and a Drag Force Field that create a simple spring and damping system (see below).
The Spherical Force Field has a property called Linear which creates a force that scales with distance between the Rigid Body and the Force Field. A negative value creates a force that attracts the Rigid Body to the Force Field, a positive value repels it. I set this to -10.0.
The Drag Force Field has a property, also called Linear, that creates a force that scales with speed. This is a damping force. I set this value to 0.1.
There is also a property called Square which creates a force that scales with the speed squared, like an aerodynamic drag force, but it’s set to 0 for now.
Press play and watch the Rigid Body oscillate up and down and eventually stop moving.
Let me know if you have any other questions.
Best,
Rick
SpringForceField.usda (5.5 KB)
By the way, Force Fields were designed to work on many Rigid Bodies simultaneously.
Joints were designed to work on just one or two Rigid Bodies at a time, so maybe a joint is a better solution to your problem.
Below is another USDA file that uses a Distance Joint instead of a Force Field.
The Spring is Enabled and the Spring Stiffness is set to 100,000 and the Spring Damping is set to 1,000 to generate similar results.
(I’d like to mention that these files use a newer version of the Force Fields extension than what has been released. So the Linear settings may need to be set to higher values when you use it.)
SpringJoint.usd (4.7 KB)
Thank you very much! I will try these 2 solutions.
Thank you again. The first example is not working while the second is working correctly.
I got another question: is it possible to make an infinite oscillation (i.e. the object continues to move without decreasing its speed)?
The first solution may not be working because I’m using an unreleased version of the Force Fields extension and the Linear settings may need to be set to 100,000 on your version.
To remove damping, set the Spring Damping to 0.
Best,
Rick
Even if I set the spring damping to 0 the object will stop, it just keeps more time to stop.
The simulation still loses a bit of energy over time…
Do you know why?
I have seen PhysX demonstrate conservation of energy, in which case the mass should oscillate forever. But I do not know why it does not work in this case.
Simulations, in general, lose energy due to floating point math errors, over time.
I would have to ask someone else or do some of my own research into the simulation to answer exactly.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.