Skip to content
lsl.devlsl.devLSL Dev

Physics

A physical object is simulated by the physics engine: it has mass, falls, collides and responds to forces. Non-physical objects stay where they are put but still collide with physical ones.

Physics settings cover the object’s status, its shape and material, how it collides, and what it reports when it hits something. Moving objects without physics is covered under Movement.

Concepts

Functions and events

voidllSetStatus(integer status, integer value)
voidllSetPhysicsMaterial(integer mask, float gravity_multiplier, float restitution, float friction, float density)
voidllApplyImpulse(vector momentum, integer is_local)
voidllSetForce(vector force, integer is_local)
voidllSetVelocity(vector velocity, integer is_local)
voidllPushObject(key target, vector impulse, vector ang_impulse, integer is_local)
listllCastRay(vector start_pos, vector end_pos, list options)
eventcollision_start(integer num_detected)
eventland_collision_start(vector pos)

Collision events

collision_start, collision and collision_end fire for objects and avatars; the land_collision events fire for the ground.

Script library

Example physics scripts from the wiki archive.

Scripting Details

voidllSetStatus(integer status, integer value)
Sets the object status attributes specified by status to value.
integerllGetStatus(integer status)
Returns a boolean integer indicating whether the specified status flag status is enabled for the object.
voidllVolumeDetect(integer detect)
If detect is TRUE, enables VolumeDetect (object becomes phantom and physical objects/avatars can pass through it). Triggers collision_start on initial intersection and collision_end when intersection stops (standard collision events are suppressed while intersecting).
floatllGetMass()
Returns a float representing the mass of the object (in lindograms). Returns the total linkset mass if called from the root, or the individual prim's mass if called from a child prim. Returns the wearer's mass if inside an attachment.
floatllGetMassMKS()
Returns a float representing the mass of the object in kilograms. Functionally identical to llGetMass except for using MKS (metric) units.
floatllGetObjectMass(key id)
Returns a float representing the mass of the avatar or object specified by id.
vectorllGetCenterOfMass()
Returns the vector position (in region coordinates) of the center of mass. Returns the individual child prim's center of mass if called from a child, or the entire linkset's center of mass if called from the root.
voidllSetPhysicsMaterial(integer mask, float gravity_multiplier, float restitution, float friction, float density)
Configures the physical characteristics of an object. The mask bitfield specifies which of the other parameters (gravity_multiplier, restitution, friction, or density) should be applied to the object.
listllGetPhysicsMaterial()
Returns a list of the format [float gravity_multiplier, float restitution, float friction, float density] detailing the physical characteristics of the object.
eventcollision_start(integer num_detected)
Triggered when an avatar or another object first begins colliding with the object containing the script. Passes num_detected, representing the number of detected collisions.
eventcollision(integer num_detected)
Triggered continuously while an avatar or another object is colliding with the object containing the script. Passes num_detected, representing the number of detected collisions.
eventcollision_end(integer num_detected)
Triggered when an avatar or another object stops colliding with the object containing the script. Passes num_detected, representing the number of detected collisions.
eventland_collision_start(vector pos)
Triggered in the root prim when a physical object or attached avatar first begins colliding with the ground at position pos.
eventland_collision(vector pos)
Triggered in the root prim when a physical object or attached avatar is colliding with the ground at position pos.
eventland_collision_end(vector pos)
Triggered in the root prim when a physical object or attached avatar stops colliding with the ground at position pos.
voidllCollisionFilter(string name, key id, integer accept)
Sets the collision filter, either exclusively or inclusively. If accept is TRUE, only collisions matching name and id are processed; if FALSE, matches are excluded. Pass an empty string or NULL_KEY to name or id to skip filtering on that parameter.
voidllPassCollisions(integer pass)
Sets the pass-collisions attribute. If pass is TRUE, collision events are passed from child prims to the root; if FALSE (default), they only trigger events in the affected child prim.
voidllCollisionSound(string impact_sound, float impact_volume)
Suppresses default collision sounds and replaces default impact sounds with impact_sound at the volume level specified by impact_volume. Supply an empty string to only suppress collision sounds.
vectorllDetectedVel(integer number)
Returns the vector velocity of the detected object or avatar specified by number, or <0.0, 0.0, 0.0> if number is not a valid offset index.
voidllApplyImpulse(vector momentum, integer is_local)
Applies a linear impulse (momentum) to a physical object. If local is TRUE, the impulse is applied in local coordinates; otherwise, it is applied in global region coordinates.
voidllApplyRotationalImpulse(vector force, integer is_local)
Applies a rotational impulse (force) to a physical object. If local is TRUE, the rotational impulse is applied in local coordinates; otherwise, it is applied in global region coordinates.
voidllSetForce(vector force, integer is_local)
Applies a constant linear force to a physical object. If local is TRUE, force is applied relative to local coordinates; if FALSE, applied relative to region coordinates.
vectorllGetForce()
Returns a vector representing the constant force currently applied to the object (if the object is physical).
voidllSetTorque(vector torque, integer is_local)
Applies a constant torque rotational force to a physical object. If local is TRUE, torque is applied in local coordinates; if FALSE, applied in global coordinates.
vectorllGetTorque()
Returns a vector representing the physical torque force currently acting on the object (if the object is physical).
voidllSetBuoyancy(float buoyancy)
Sets the buoyancy of a physical object (requires physics to be enabled). A value of 0.0 offers no buoyancy, < 1.0 sinks, 1.0 counteracts gravity, and > 1.0 rises.
voidllPushObject(key target, vector impulse, vector ang_impulse, integer is_local)
Applies physical impulse (force) and ang_impulse (rotational force) to the specified target avatar or object.
voidllSetVelocity(vector velocity, integer is_local)
Sets the linear velocity of a physical object to velocity. If local is TRUE, velocity is treated as a local directional vector; if FALSE, as a global region directional vector. Has no effect on non-physical objects.
vectorllGetVel()
Returns a vector representing the velocity of the object (in meters per second) relative to the global region coordinates. For physical objects, returns the velocity of its center of mass.
listllCastRay(vector start_pos, vector end_pos, list options)
Casts a ray into the physics world from start to end and reports collision data for intersections with objects based on options. Returns a list of strided values [UUID_1, {link_number_1}, hit_position_1, {hit_normal_1}, ..., status_code]. A negative status_code indicates an error; otherwise, it represents the number of hits.
floatllGetRegionTimeDilation()
Returns a float representing the current physics time dilation of the region, ranging from 0.0 (full dilation / slow) to 1.0 (no dilation / real-world speed).
floatllGetSimStats(integer stat_type)
Returns a float containing the value of the requested region statistic specified by stat_type.
floatllGetEnergy()
Returns a float representing the remaining physics energy of the object as a percentage (0.0 to 1.0) of its maximum capacity.

Additional

Constant groups ObjectStatusParam 11PhysicsMaterialParam 4PhysicsMaterialPreset 7PhysicsShapeType 3RayCastParam 4RayCastRejectType 4RayCastData 3RayCastError 3

See also Category PhysicsSL Wiki LSL PhysicsSL Wiki LSL Collision EventsSL Wiki Script library: physicsFeature MovementFeature CombatPage Guide: interpolation and easingPlanned Guide: physics materials