Difference between revisions of "LlSetBuoyancy"

From Second Life Wiki
Jump to navigation Jump to search
(Undo revision 1184712 by Strife Onizuka (Talk) brain fart)
m (Added a small indent, makes the explanations look so much nicer this way!)
 
(2 intermediate revisions by 2 users not shown)
Line 10: Line 10:
|caveats=*[[llWind|Wind]] can cause the prim to drift. (server 1.38.4 this appears not to be true)
|caveats=*[[llWind|Wind]] can cause the prim to drift. (server 1.38.4 this appears not to be true)
*Unlike some other characteristics, a buoyancy effect is cancelled if the script that set buoyancy is removed from the prim.
*Unlike some other characteristics, a buoyancy effect is cancelled if the script that set buoyancy is removed from the prim.
*This function cannot be used to set relative levels of buoyancy in parts of a linked object e.g. to simulate a helium balloon weighted by its string. The most recent call of <code>llSetBuoyancy</code> in any child prim appears to set the global buoyancy level for the object.
*This function cannot be used to set relative levels of buoyancy in parts of a linked object, e.g. to simulate a helium balloon weighted by its string. The most recent call of <code>llSetBuoyancy</code> in any child prim appears to set the global buoyancy level for the object.
*This function eats [[energy]] to keep the object floating. Large objects may not be able to supply enough energy to keep the object floating.  
*This function eats [[energy]] to keep the object floating. Large objects may not be able to supply enough energy to keep the object floating.  
* For better performance, replace by [[llSetPhysicsMaterial]](GRAVITY_MULTIPLIER, gravity, 0.0,0.0,0.0) which doesn't eat energy
* For better performance, replace by <code>[[llSetPhysicsMaterial]]([[GRAVITY_MULTIPLIER]], gravity, 0.0, 0.0, 0.0)</code> which doesn't consume energy.
<br> For example, replace llSetBuoyancy(1.5) by llSetPhysicsMaterial( GRAVITY_MULTIPLIER, -0.5 ,0.0, 0.0, 0.0 ) to raise an object; replace llSetBuoyancy(1.0) by llSetPhysicsMaterial( GRAVITY_MULTIPLIER, 0.0 ,0.0, 0.0, 0.0 ) to float an object
:For example, replace <code>llSetBuoyancy(1.5)</code> by <code>llSetPhysicsMaterial(GRAVITY_MULTIPLIER, -0.5 ,0.0, 0.0, 0.0)</code> to raise an object; replace <code>llSetBuoyancy(1.0)</code> by <code>llSetPhysicsMaterial(GRAVITY_MULTIPLIER, 0.0 ,0.0, 0.0, 0.0)</code> to float an object
* When buoyancy is changed, the object briefly continues to be affected by the last value. For example, if buoyancy was set it to 1.5 to raise an object, and whilst moving, buoyancy is changed it to 0.0, the object continues to rise for a moment, because the force is not reversed, only cancelled. With llSetPhysicsMaterial( GRAVITY_MULTIPLIER, -0.5 ,0.0, 0.0, 0.0 ) followed by llSetPhysicsMaterial( GRAVITY_MULTIPLIER, 1.0 ,0.0, 0.0, 0.0 ), the change in movement is immediate, and the object starts to fall at the instant that the second call is done.
* When buoyancy is changed, the object briefly continues to be affected by the last value. For example, if buoyancy was set it to 1.5 to raise an object, and whilst moving, buoyancy is changed it to 0.0, the object continues to rise for a moment, because the force is not reversed, only cancelled. With <code>llSetPhysicsMaterial(GRAVITY_MULTIPLIER, -0.5 ,0.0, 0.0, 0.0)</code> followed by <code>llSetPhysicsMaterial(GRAVITY_MULTIPLIER, 1.0 ,0.0, 0.0, 0.0)</code>, the change in movement is immediate, and the object starts to fall at the instant that the second call is done.
|constants .
|constants .
|examples=Makes an object float up slowly (e.g. a red balloon)<lsl>default
|examples=Makes an object float up slowly (e.g. a red balloon)<syntaxhighlight lang="lsl2">default
{
{
     state_entry()
     state_entry()
Line 23: Line 23:
         llSetBuoyancy(1.05);
         llSetBuoyancy(1.05);
     }
     }
}</lsl>
}</syntaxhighlight>
|helpers
|helpers
|also_functions
|also_functions
Line 30: Line 30:
|also_articles
|also_articles
|notes=Often used to make an object appear to be unaffected by gravity.
|notes=Often used to make an object appear to be unaffected by gravity.
|haiku={{Haiku|A buoy in the sea|Rising with the swell of waves|Bobbing up and down}}
|cat1=Hover
|cat1=Hover
|cat2=Physics
|cat2=Physics

Latest revision as of 18:40, 20 October 2023

Summary

Function: llSetBuoyancy( float buoyancy );

Sets the buoyancy of the task or object. Requires physics to be enabled.

• float buoyancy

A buoyancy value of 0.0 disables the effect
when buoyancy is < 1.0, the object sinks
when buoyancy equals 1.0 it floats
when buoyancy is > 1.0 the object rises

Caveats

  • Wind can cause the prim to drift. (server 1.38.4 this appears not to be true)
  • Unlike some other characteristics, a buoyancy effect is cancelled if the script that set buoyancy is removed from the prim.
  • This function cannot be used to set relative levels of buoyancy in parts of a linked object, e.g. to simulate a helium balloon weighted by its string. The most recent call of llSetBuoyancy in any child prim appears to set the global buoyancy level for the object.
  • This function eats energy to keep the object floating. Large objects may not be able to supply enough energy to keep the object floating.
  • For better performance, replace by llSetPhysicsMaterial(GRAVITY_MULTIPLIER, gravity, 0.0, 0.0, 0.0) which doesn't consume energy.
For example, replace llSetBuoyancy(1.5) by llSetPhysicsMaterial(GRAVITY_MULTIPLIER, -0.5 ,0.0, 0.0, 0.0) to raise an object; replace llSetBuoyancy(1.0) by llSetPhysicsMaterial(GRAVITY_MULTIPLIER, 0.0 ,0.0, 0.0, 0.0) to float an object
  • When buoyancy is changed, the object briefly continues to be affected by the last value. For example, if buoyancy was set it to 1.5 to raise an object, and whilst moving, buoyancy is changed it to 0.0, the object continues to rise for a moment, because the force is not reversed, only cancelled. With llSetPhysicsMaterial(GRAVITY_MULTIPLIER, -0.5 ,0.0, 0.0, 0.0) followed by llSetPhysicsMaterial(GRAVITY_MULTIPLIER, 1.0 ,0.0, 0.0, 0.0), the change in movement is immediate, and the object starts to fall at the instant that the second call is done.
All Issues ~ Search JIRA for related Bugs

Examples

Makes an object float up slowly (e.g. a red balloon)
default
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSetBuoyancy(1.05);
    }
}

Notes

Often used to make an object appear to be unaffected by gravity.

Deep Notes

Search JIRA for related Issues

Signature

function void llSetBuoyancy( float buoyancy );

Haiku

A buoy in the sea
Rising with the swell of waves
Bobbing up and down