Don't click here unless you want to be banned.

LSL Wiki : llSetForce

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl801.us.archive.org
llSetForce(vector force, integer local);

Sets the force to be continuously applied on the (attached) object. When local is TRUE then force is relative to the object's own (potentially rotated) axes; when FALSE it is relative to the simulator's axes.

The object must be physical for this to take effect. See physics for information on how forces affect physical objects.

If you want only an impulse, use llApplyImpulse instead.

You can also set force and torque simultaneously by using llSetForceAndTorque.

Do not use with vehicles.

Example:

To levitate an object, apply an upwards force proportional to its mass. Rez a prim, enable physics, and execute the following in a script:
float mass = llGetMass(); // mass of this object
float gravity = 9.8; // gravity constant
llSetForce(mass * <0,0,gravity>, FALSE); // in global orientation

The prim will now appear weightless and still possess inertia.
Note: With large/very massive objects, the object may not have enough energy to sustain the continuous force and will still fall to the ground.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Dynamics
Comments [Hide comments/form]
Is there a difference between:

llSetForce(<1,0,0> * llGetRot(), FALSE);

and

llSetForce(<1,0,0>, TRUE);?

Im wondering if the latter will keep the force in the direction of the fwd axis constantly, no matter if the object is rotated while the force is being applied.
-- ChristopherOmega (2004-03-09 21:04:45)
why is it a bad idea to use llSetForce with vehicles?
-- SiroMfume (2004-08-23 15:27:14)
Presumably because llSetForce applies the force persistently, which is probably not the desired behavior in a vehicle -- you'd want to apply an impulse only while the driver is holding a directional key. Granted, you could probably work around that by only llSetForceing when the key goes down and setting it to zero when it comes back up, but why would you do something like that?

Also, llSetForce and the vehicle physics could possibly interact in strange ways (because of the aforementioned properties of llSetForce, etc).
-- GabrielSpinnaker (2004-08-25 19:59:28)
In answer to CristopherOmega's question and my own:
llSetForce will set a static force on the rotation it is initially set at. So if you rotate away from it via llSetTorque for instance, or llRotLookAt, the force will still be applied along it's previous axis until it is canceled.

Further, I learned that cancelling the force will not cancel the accumulated velocity. THIS is why it is bad for vehicles. This applies to llSetTorque too. It's not just that the force is applied persistently, it's that the accumulated velocity from that force doesn't go away when the force is canceled. So you'd need to call further functions to cancel the velocity by applying impulses anyway.
-- SiroMfume (2004-09-02 20:12:22)
you can use it for a substitute for orbit
-- Turnni1 (2007-01-10 02:40:57)
Attach a comment to this page: