Loading...
Loading...
Apply physics forces to the player in Decentraland scenes. Impulses (one-shot pushes), knockback (push away from a point with falloff), continuous forces (wind tunnels, anti-gravity, lift, hover), timed forces, and repulsion fields. Use when the user wants launch pads, knockback on hit, wind zones, gravity fields, or lifting/floating/hovering the player. THIS is also the right skill when an agent's first instinct is to mutate `Transform` on `engine.PlayerEntity` to move/lift/push the player — that does NOT work (player Transform is engine-controlled and read-only); use the Physics API instead. Do NOT use for player movement speed (see player-avatar AvatarLocomotionSettings) or platform movement (see animations-tweens).
npx skill4agent add decentraland/sdk-skills player-physicsPhysics@dcl/sdk/ecsTransformengine.PlayerEntityTransform.getMutableTransform.createOrReplace.position.rotationPhysicsmovePlayerTo~system/RestrictedActionsplayer-avatar// WRONG — has no effect in-world
const t = Transform.getMutable(engine.PlayerEntity)
t.position.y += 0.1 // ignored every frame
// CORRECT — lift the player upward
import { Physics } from '@dcl/sdk/ecs'
import { Vector3 } from '@dcl/sdk/math'
Physics.applyImpulseToPlayer(Vector3.create(0, 50, 0)) // one-shot upward launch
// or, sustained lift / hover:
const lifter = engine.addEntity()
Physics.applyForceToPlayer(lifter, Vector3.create(0, 1, 0), 12) // continuous upward force
// stop with: Physics.removeForceFromPlayer(lifter)Physics.applyImpulseToPlayer(direction, magnitude?)Physics.applyKnockbackToPlayer(sourcePos, magnitude, radius?, falloff?)| Falloff | Behavior |
|---|---|
| Same magnitude at any distance within radius (default) |
| Smooth linear decrease to 0 at the radius edge |
| Sharp, physically-realistic drop-off |
applyRepulsionForceToPlayer()KnockbackFalloff.LINEARPhysics.applyForceToPlayer(entity, direction, magnitude?)Physics.removeForceFromPlayer(entity)Physics.applyForceToPlayerForDuration(entity, seconds, direction, magnitude?)Physics.applyRepulsionForceToPlayer(entity, position, magnitude, radius)Physics.removeForceFromPlayer(entity)Transform.localToWorldDirection(entity, localDir)| Method | Type | Description |
|---|---|---|
| One-shot | Instant directional push |
| One-shot | Push away from point |
| Continuous | Persistent push while active |
| Control | Stop a continuous force |
| Timed | Force that expires automatically |
| Continuous | Distance-based push from point |
| Utility | Convert local direction to world space |
Physics.*TriggerArea5,5-collider-layers| Mask | Fires for |
|---|---|
| the local player only |
| remote avatars only (NOT the local player) |
| both local and remote |
| never fires for any avatar (targets scene mesh/walls, not characters) |
CL_MAIN_PLAYERCL_PLAYERCL_PLAYER | CL_MAIN_PLAYERresult.trigger?.entity === engine.PlayerEntityresult.trigger?.entityresult.triggeredEntityPlayerEntityapplyForceToPlayerapplyForceToPlayerForDurationapplyRepulsionForceToPlayerglidingFallingSpeedAvatarLocomotionSettingsapplyImpulseToPlayerapplyKnockbackToPlayer{baseDir}/references/physics-patterns.md