Menu
Lumberyard
Developer Guide (Version 1.12)

ScriptBind_Physics

CryLua is deprecated and will be removed in a future version of Lumberyard.

Lists C++ physics functions that you can call from Lua script.

RayTraceCheck

Checks if a ray segment intersects anything from its source to its destination.

Syntax

Copy
Physics.RayTraceCheck(Vec3 src,Vec3 dst,ScriptHandle skipEntityId1,ScriptHandle skipEntityId2)

Parameter Description
src The origin point of the ray segment.
dst The end point of the ray segment.
skipEntityId1 Entity ID to skip when checking for intersection.
skipEntityId2 Entity ID to skip when checking for intersection.

RayWorldIntersection

Checks if a ray segment intersects anything from its source to its destination.

Syntax

Copy
Physics.RayWorldIntersection(Vec3 vPos, Vec3 vDir, int nMaxHits, int iEntTypes [, skipEntityId1 [, skipEntityId2]])

Parameter Description
vPos The origin point of the ray.
vDir The direction of the ray.
nMaxHits The maximum number of hits to return, sorted in nearest to farthest order.
iEntTypes A bitmask of physical entity types. The ray intersects only with entities that the mask specifies (ent_all,...).
skipEntityId1 Optional. An entity ID to skip when checking for intersection.
skipEntityId2 Optional. An entity ID to skip when checking for intersection.

RegisterExplosionCrack

Registers a new crack for a breakable object.

Syntax

Copy
Physics.RegisterExplosionCrack(const char *sGeometryFile,int nIdMaterial)

Parameter Description
sGeometryFile The name of the static geometry file for the crack (CGF).
nMaterialId The ID of the breakable material to which the crack is applied.

RegisterExplosionShape

Registers a new explosion shape from static geometry.

Note

RegisterExplosionShape applies only physical forces; it does not apply any game related explosion damages.

Syntax

Copy
Physics.RegisterExplosionShape(RegisterExplosionShape(IFunctionHandler *pH,const char *sGeometryFile,float fSize,int nIdMaterial,float fProbability,const char *sSplintersFile, float fSplintersOffset, const char *sSplintersCloudEffect)

Parameter Description
sGeometryFile The name of the static geometry file (CGF).
fSize The scale for the static geometry.
nIdMaterial The ID of the breakable material on which the shape is applied.
fProbability The preference ratio for using this shape instead of other registered shapes.
sSplintersFile The name of a CGF file that contains additional non-physicalized splinters to place on cut surfaces.
fSplintersOffset The lower splinters position in relation to the upper one.
sSplintersCloudEffect The particle effect when the splinters constraint breaks.

SamplePhysEnvironment

Find the physical entities touched by a sphere.

Syntax

Copy
Physics.SamplePhysEnvironment(pt, r [, objtypes])

Parameter Description
pt The center of the sphere.
r The radius of the sphere.
objtypes Optional. The types of physical entities that the sphere touches.

SimulateExplosion

Simulates a physical explosion.

Note

SimulateExplosion applies only physical forces; it does not apply any game related explosion damages.

Syntax

Copy
Physics.SimulateExplosion(SmartScriptTable explosionParams)

explosionParams is a SmartScriptTable whose elements are as follows:

explosionParams Elements

Parameter Description
pos The epicenter of the explosion.
radius The radius of the explosion.
direction The direction of the explosion impulse.
impulse_pos The position of the explosion impulse. This value can be different from the epicenter of the explosion.
impulse_presure The pressure of the explosion impulse at the specified radius from the epicenter.
rmin The minimal radius of the explosion. At this radius, full pressure is applied.
rmax The maximum radius of the explosion. At this radius, the impulse pressure is close to zero.
hole_size The size of the hole that the explosion creates in breakable objects.