Skip to content

$physics

Ray casts, overlaps, rigid bodies and collision.

119 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types).

apply_force_to_bones_near_position

$physics.apply_force_to_bones_near_position(binding: Reference, force: vec3, torque: vec3, position: vec3, max_distance: float, as_impulse: bool) -> bool

Applies force to physics bones within the given distance of the given position.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
forcevec3The force to apply.
torquevec3The torque to apply.
positionvec3The world position to check against.
max_distancefloatThe max distance to check against.
as_impulseboolWhether to apply force as central impulse and torque as torque impulse.

Returns bool: Whether applying the force was successful.

arbitrary_mesh_from_world

$physics.arbitrary_mesh_from_world(mesh: Reference, p0: vec3) -> Reference

Declare a physical arbitrary mesh for this frame.

ParameterTypeMeaning
meshReferenceThe mesh to create the physics shape from.
p0vec3The initial mesh location offset.

Returns Reference: Handle to a physics convex mesh.

are_physics_bones_shapes_created

$physics.are_physics_bones_shapes_created(binding: Reference) -> bool

Returns whether physics shapes have been created for a physics bones. Shapes are not created until the second frame that a physics bones is created.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.

Returns bool: Whether physics shapes have been created for a physics_bones.

blend_bones

$physics.blend_bones(binding: Reference, position: vec3, rotation: vec4, scale: vec3, entity: Entity, blend_factor: float, allowed_error: float, use_rest_pose: bool) -> bool

Blends animation data into physics bones.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
positionvec3The position of the physics bones.
rotationvec4The rotation of the physics bones.
scalevec3The scale of the physics bones.
entityEntityThe entity to retrieve the animation pose from (see animation.set_model_pose).
blend_factorfloatBlend weight for physics bones relative to animation between 0 (full anim) and 1 (full physics).
allowed_errorfloatAllowed world unit error when posing skeleton. Higher values allow faster processing
use_rest_poseboolSample the rest pose and pass that to the physics simulation for the bones.

Returns bool: Whether the physics bones were blended or not.

bones

$physics.bones(bones_data: Reference, collision_group: Reference, collision_layer: Reference, restart_id: int) -> Reference

Creates physics bones.

ParameterTypeMeaning
bones_dataReferencePhysics bones data definition.
collision_groupReferenceCollision group file.
collision_layerReferenceCollision layer file.
restart_idintA number that can be incremented to force the physics bones to be re-created.

Returns Reference: Handle to a physics bones.

bones_get_root_position

$physics.bones_get_root_position(binding: Reference, fallback_position: vec3) -> vec3

Gets root position of the physics bone set.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
fallback_positionvec3The position to return in case the physics_bones's position is not yet available.

Returns vec3: Root bone position, or fallback_position if not available.

bones_get_root_rotation

$physics.bones_get_root_rotation(binding: Reference) -> vec4

Gets root rotation of the physics bones set.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.

Returns vec4: Root bone rotation.

bones_get_shape_by_index

$physics.bones_get_shape_by_index(binding: Reference, index: int) -> Reference

Gets the physics shape by shape index in physics bones

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
indexintThe index

Returns Reference: Physics (shape) bone.

bones_rollback_enabled

$physics.bones_rollback_enabled() -> bool

Check if rollback is enabled for physics bones

Returns bool: Returns true if physics bones rollback is enabled, false otherwise.

box_from_world

$physics.box_from_world(p0: vec3, size: vec3, mass: float) -> Reference

Declare a physical box for this frame.

ParameterTypeMeaning
p0vec3The initial box position offset.
sizevec3The box size offset.
massfloatThe box mass.

Returns Reference: Handle to a physics box.

capsule_cast

$physics.capsule_cast(start_pos: vec3, end_pos: vec3, radius: float, height: float, collision_info: Reference, visuals_world: bool) -> Reference

Performs a capsule swept convex cast from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
radiusfloatRadius of the capsule.
heightfloatHeight of the capsule.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

capsule_cast_all

$physics.capsule_cast_all(start_pos: vec3, end_pos: vec3, radius: float, height: float, collision_info: Reference, visuals_world: bool) -> Reference

Performs a capsule swept convex cast from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
radiusfloatRadius of the capsule.
heightfloatHeight of the capsule.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to a list of all objects hit

capsule_cast_all_multi

$physics.capsule_cast_all_multi(positions: list, radius: float, height: float, collision_info: Reference, visuals_world: bool) -> Reference

Casts a capsule through the given positions (Hit Fraction is per segment rather than the complete ray).

ParameterTypeMeaning
positionslistWhere the ray will start.
radiusfloatradius of the sphere.
heightfloatHeight of the sphere.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to a list of all objects hit

capsule_cast_multi

$physics.capsule_cast_multi(positions: list, radius: float, height: float, collision_info: Reference, visuals_world: bool) -> Reference

Casts a capsule through the given positions (Hit Fraction is per segment rather than the complete ray).

ParameterTypeMeaning
positionslistWhere the ray will start.
radiusfloatRadius of the capsule.
heightfloatRadius of the capsule.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

capsule_from_world

$physics.capsule_from_world(p0: vec3, height: float, radius: float, mass: float) -> Reference

Declare a physical capsule for this frame.

ParameterTypeMeaning
p0vec3The initial capsule location offset.
heightfloatThe capsule height.
radiusfloatThe capsule radius.
massfloatThe capsule mass.

Returns Reference: Handle to a physics capsule.

carpg_set_collision_params

$physics.carpg_set_collision_params(player_collision_group: Reference, ai_collision_group: Reference, collision_roll_factor: float)

Set carpg project custom collision parameters.

ParameterTypeMeaning
player_collision_groupReferenceThe collision group of the player collider.
ai_collision_groupReferenceThe collision group of the AI physics vehicle colliders.
collision_roll_factorfloatValue in [0.0, 1.0] .Greater values causes greater reduction in pitch / roll torque due to collision with the player.

compound_group_from_world

$physics.compound_group_from_world(compound_group: Reference, p0: vec3) -> Reference

Declare a physical arbitrary mesh for this frame.

ParameterTypeMeaning
compound_groupReferenceThe mesh to create the physics shape from.
p0vec3The initial mesh location offset.

Returns Reference: Handle to a physics convex mesh.

cone_from_world

$physics.cone_from_world(p0: vec3, height: float, radius: float, mass: float) -> Reference

Declare a physical cone for this frame.

ParameterTypeMeaning
p0vec3The initial cone location offset.
heightfloatThe cone height.
radiusfloatThe cone radius.
massfloatThe cone mass.

Returns Reference: Handle to a physics cone.

constraint_6dof_spring

$physics.constraint_6dof_spring(shape_a: Reference, shape_b: Reference, offset_a: vec3, offset_b: vec3, is_visual: bool) -> Reference

create a 6dof constraint between two physics shapes.

ParameterTypeMeaning
shape_aReferenceThe handle to the constraint physics shape.
shape_bReferenceThe handle to the child physics shape.
offset_avec3Offset of shape a.
offset_bvec3Offset of shape b.
is_visualboolTrue if constraint is visual.

Returns Reference: Handle to a 6dof spring physics constraint.

constraint_6dof_spring_to_world

$physics.constraint_6dof_spring_to_world(shape: Reference, offset: vec3, is_visual: bool) -> Reference

create a 6dof constraint fixed to this entity's world transform.

ParameterTypeMeaning
shapeReferenceThe handle to the physics shape.
offsetvec3Translational offset between the constraint and the shape.
is_visualboolTrue if constraint is visual.

Returns Reference: Handle to a 6dof spring physics constraint.

constraint_enable_spring

$physics.constraint_enable_spring(constraint: Reference, axis_mask: int)

enables the spring on a 6dof constraint.

ParameterTypeMeaning
constraintReferenceHandle to a 6dof physics constraint.
axis_maskintThe axis mask.

constraint_set_cfm

$physics.constraint_set_cfm(constraint: Reference, angular_cfm: vec3, angular_stop_cfm: vec3, linear_cfm: vec3, linear_stop_cfm: vec3)

set the cfm and stop_cfm on a 6dof constraint.

ParameterTypeMeaning
constraintReferenceHandle to a 6dof physics constraint.
angular_cfmvec3The angular cfm to apply.
angular_stop_cfmvec3The angular stop_cfm to apply.
linear_cfmvec3The linear cfm to apply.
linear_stop_cfmvec3The linear stop_cfm to apply.

constraint_set_damping

$physics.constraint_set_damping(constraint: Reference, angular_damping: vec3, linear_damping: vec3)

set the damping on a 6dof constraint.

ParameterTypeMeaning
constraintReferenceHandle to a 6dof physics constraint.
angular_dampingvec3The angular damping to apply.
linear_dampingvec3The linear damping to apply.

constraint_set_erp

$physics.constraint_set_erp(constraint: Reference, angular_erp: vec3, angular_stop_erp: vec3, linear_erp: vec3, linear_stop_erp: vec3)

set the erp and stop_erp on a 6dof constraint.

ParameterTypeMeaning
constraintReferenceHandle to a 6dof physics constraint.
angular_erpvec3The angular erp to apply.
angular_stop_erpvec3The angular stop_erp to apply.
linear_erpvec3The linear erp to apply.
linear_stop_erpvec3The linear stop_erp to apply.

constraint_set_limits

$physics.constraint_set_limits(constraint: Reference, linear_lo_limit: vec3, linear_hi_limit: vec3, angular_lo_limit: vec3, angular_hi_limit: vec3)

set the linear and angular limits on a 6dof constraint.

ParameterTypeMeaning
constraintReferenceHandle to a 6dof physics constraint.
linear_lo_limitvec3The lower linear limit to apply.
linear_hi_limitvec3The linear high limit to apply.
angular_lo_limitvec3The angular low limit to apply.
angular_hi_limitvec3The angular high limit to apply.

constraint_set_stiffness

$physics.constraint_set_stiffness(constraint: Reference, angular_stiffness: vec3, linear_stiffness: vec3)

set the stiffness on a 6dof constraint.

ParameterTypeMeaning
constraintReferenceHandle to a 6dof physics constraint.
angular_stiffnessvec3The angular stiffness to apply.
linear_stiffnessvec3The linear stiffness to apply.

convex_mesh_from_world

$physics.convex_mesh_from_world(mesh: Reference, p0: vec3, mass: float) -> Reference

Declare a physical convex mesh for this frame.

ParameterTypeMeaning
meshReferenceThe mesh to create the physics shape from.
p0vec3The initial mesh location offset.
massfloatThe mesh mass.

Returns Reference: Handle to a physics convex mesh.

cylinder_cast

$physics.cylinder_cast(start_pos: vec3, end_pos: vec3, radius: float, height: float, collision_info: Reference, visuals_world: bool) -> Reference

Performs a cylinder swept convex cast from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
radiusfloatRadius of the capsule.
heightfloatHeight of the capsule.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

cylinder_cast_all

$physics.cylinder_cast_all(start_pos: vec3, end_pos: vec3, radius: float, height: float, collision_info: Reference, visuals_world: bool) -> Reference

Performs a cylinder swept convex cast from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
radiusfloatRadius of the cylinder.
heightfloatHeight of the cylinder.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to a list of all objects hit

cylinder_from_world

$physics.cylinder_from_world(p0: vec3, size: vec2, mass: float) -> Reference

Declare a physical cylinder for this frame.

ParameterTypeMeaning
p0vec3The initial cylinder position offset.
sizevec2The cylinder extents.
massfloatThe cylinder mass.

Returns Reference: Handle to a physics cylinder.

get_activation_state

$physics.get_activation_state(object: Reference) -> int

Set the shape's activation state, which determines how it behaves in the world.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.

Returns int: Activation state of physics object.

get_angular_velocity

$physics.get_angular_velocity(object: Reference) -> vec3

Get the angular velocity of a physics object.

ParameterTypeMeaning
objectReferenceHandle to a physics object.

Returns vec3: Velocity of physics object.

get_closest_bone_index_to_position

$physics.get_closest_bone_index_to_position(binding: Reference, position: vec3) -> int

Gets the closest physics bone to the given world position.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
positionvec3The world position to check against.

Returns int: Physics (shape) bone index, or -1 if no shape available.

get_closest_bone_to_position

$physics.get_closest_bone_to_position(binding: Reference, position: vec3) -> Reference

Gets the closest physics bone to the given world position.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
positionvec3The world position to check against.

Returns Reference: Physics (shape) bone.

get_collision_info

read-only
$physics.get_collision_info(component: Component) -> Reference

Get a handle to the collision info for this shape.

ParameterTypeMeaning
componentComponentThe component to get the collision info handle from.

Returns Reference: Handle to the shapes collision info.

get_collision_info_applied_impulse

read-only
$physics.get_collision_info_applied_impulse(info: Reference, index: int) -> float

Get the physics applied impulse at the given index from the given collision info.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.
indexintIndex into the collision info.

Returns float: The magnitude of applied impulse

get_collision_info_component

read-only
$physics.get_collision_info_component(info: Reference, index: int) -> Component

Get the physics component on object at the given index from the given collision info.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.
indexintIndex into the collision info.

Returns Component: Handle to a component that collided, or null if none.

get_collision_info_count

read-only
$physics.get_collision_info_count(info: Reference) -> int

Get the count of collisions for the given collision handle.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.

Returns int: The count of collisions.

get_collision_info_normal

read-only
$physics.get_collision_info_normal(info: Reference, index: int) -> vec3

Get the physics normal at the given index from the given collision info.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.
indexintIndex into the collision info.

Returns vec3: The normal of the collided object.

get_collision_info_position

read-only
$physics.get_collision_info_position(info: Reference, index: int) -> vec3

Get the physics normal at the given index from the given collision info.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.
indexintIndex into the collision info.

Returns vec3: The position of the collided object.

get_collision_info_shape

read-only
$physics.get_collision_info_shape(info: Reference, index: int) -> Reference

Get the physics shape at the given index from the given collision info.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.
indexintIndex into the collision info.

Returns Reference: Handle to a shape that collided, or null if none.

get_collision_info_user_index

read-only
$physics.get_collision_info_user_index(info: Reference, index: int) -> int

Get the user index for the shape at the given index from the given collision info.

ParameterTypeMeaning
infoReferenceHandle to a shapes collision info.
indexintIndex into the collision info.

Returns int: User index of shape (or sub-shape).

get_component_shape

$physics.get_component_shape(component: Component) -> Reference

Get a handle to the shape created by this component.

ParameterTypeMeaning
componentComponentThe component.

Returns Reference: Handle to the shape.

get_deactivation_time

$physics.get_deactivation_time(object: Reference) -> float

Set the shape's deactivation time, which determines how it deactivates in the world.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.

Returns float: Deactivation time of physics object.

get_gravity

read-only
$physics.get_gravity() -> vec3

Get the gravity of the physics world.

Returns vec3: The current value of gravity.

get_inverse_world_scale

read-only
$physics.get_inverse_world_scale() -> float

Get the inverse scale of the physics world relative to the engine (e.g. m->cm)

Returns float: The current value of physics inverse world scale.

get_linear_velocity

$physics.get_linear_velocity(object: Reference) -> vec3

Get the linear velocity of a physics object.

ParameterTypeMeaning
objectReferenceHandle to a physics object.

Returns vec3: Velocity of physics object.

get_position

$physics.get_position(object: Reference) -> vec3

Get the position a physical sphere.

ParameterTypeMeaning
objectReferenceHandle to a physics object.

Returns vec3: Position of physics object.

get_raycast_info_component

$physics.get_raycast_info_component(info: Reference) -> Component

Get the physics component on the object from the given raycast hit info.

ParameterTypeMeaning
infoReferenceHandle to a raycast hit info.

Returns Component: Handle to a raycast hit component.

get_raycast_info_hit_fraction

$physics.get_raycast_info_hit_fraction(info: Reference) -> float

Returns hit fraction between 0.0 and 1.0 where 0.0 is origin and 1.0 is destination.

ParameterTypeMeaning
infoReferenceHandle to a raycast hit info.

Returns float: The object hit fraction along the ray.

get_raycast_info_normal

$physics.get_raycast_info_normal(info: Reference) -> vec3

Get the hit normal from the given raycast hit info.

ParameterTypeMeaning
infoReferenceHandle to a raycast hit info.

Returns vec3: The raycast hit normal

get_raycast_info_position

$physics.get_raycast_info_position(info: Reference) -> vec3

Get the hit position from the given raycast hit info.

ParameterTypeMeaning
infoReferenceHandle to a raycast hit info.

Returns vec3: The raycast hit position

get_raycast_info_shape

$physics.get_raycast_info_shape(info: Reference) -> Reference

Returns the (opaque) physics shape hit by a ray.

ParameterTypeMeaning
infoReferenceHandle to a raycast hit info.

Returns Reference: Handle to the physics shape hit by the ray.

get_raycast_info_user_index

$physics.get_raycast_info_user_index(info: Reference) -> int

Returns the user_index for the shape hit by a ray.

ParameterTypeMeaning
infoReferenceHandle to a raycast hit info.

Returns int: The user index of the shape hit by the ray..

get_rotation

$physics.get_rotation(object: Reference) -> vec4

Get the rotation a physical sphere.

ParameterTypeMeaning
objectReferenceHandle to a physics object.

Returns vec4: Rotation of physics object.

get_world_scale

read-only
$physics.get_world_scale() -> float

Get the scale of the physics world relative to the engine (e.g. cm ->m)

Returns float: The current value of physics world scale.

physics_bones_disable_gravity

$physics.physics_bones_disable_gravity(binding: Reference, state: bool)

Whether gravity will be disabled on a set of physics bones for the current frame.

ParameterTypeMeaning
bindingReferenceThe physics bones binding.
stateboolThe force to apply.

raycast

$physics.raycast(start_pos: vec3, end_pos: vec3, collision_info: Reference, visuals_world: bool) -> Reference

Casts a ray from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

raycast_all

$physics.raycast_all(start_pos: vec3, end_pos: vec3, collision_info: Reference, visuals_world: bool) -> list

Casts a ray from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns list: Handle to a list of all objects hit

raycast_all_multi

$physics.raycast_all_multi(positions: list, collision_info: Reference, visuals_world: bool) -> Reference

Casts a ray through the given positions (Hit Fraction is per segment rather than the complete ray).

ParameterTypeMeaning
positionslistWhere the ray will start.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to a list of all objects hit

raycast_multi

$physics.raycast_multi(positions: list, collision_info: Reference, visuals_world: bool) -> Reference

Casts a ray through the given positions (Hit Fraction is per segment rather than the complete ray).

ParameterTypeMeaning
positionslistWhere the ray will start.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

set_gravity

$physics.set_gravity(gravity: vec3)

Set the gravity of the physics world.

ParameterTypeMeaning
gravityvec3Value to set the physics world gravity to.

set_visuals_collision_mask

$physics.set_visuals_collision_mask(collision_mask: Reference)

Set the collision mask for the visuals world.

ParameterTypeMeaning
collision_maskReferenceCollision layers file.

set_world_scale

$physics.set_world_scale(scale: float)

Set the scale of the physics world relative to the engine (e.g. cm->m)

ParameterTypeMeaning
scalefloatValue to set the physics world scale to.

shape_activation_state

$physics.shape_activation_state(object: Reference, activation_state: int)

Set the shape's activation state, which determines how it behaves in the world.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
activation_stateintActivation state.

shape_allow_rotation

$physics.shape_allow_rotation(object: Reference, allow_rotation: bool)

Set if this object can rotate from external forces.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
allow_rotationboolWhether the object is allowed to rotate from external forces

shape_angular_factor

$physics.shape_angular_factor(object: Reference, angular_factor: vec3)

Set the angular factor of a shape, which determines to what degree torque causes rotation about each axis.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
angular_factorvec3The angular factor.

shape_angular_velocity

$physics.shape_angular_velocity(object: Reference, velocity: vec3)

Set angular velocity on a shape for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
velocityvec3The friction to apply

shape_ccd_motion_threshold

$physics.shape_ccd_motion_threshold(object: Reference, motion_threshold: float)

Set the motion threshold on a shape for continuous collision detection.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
motion_thresholdfloatThe motion threshold.

shape_ccd_swept_sphere_radius

$physics.shape_ccd_swept_sphere_radius(object: Reference, radius: float)

Set the swept sphere radius on a shape for continuous collision detection .

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
radiusfloatThe swept sphere radius.

shape_collision_group

$physics.shape_collision_group(object: Reference, collision_info: Reference)

Set the given shapes collision group for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
collision_infoReferenceCollision group file.

shape_collision_mask

$physics.shape_collision_mask(object: Reference, collision_info: Reference)

Set the given shapes collision mask for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
collision_infoReferenceCollision layers file.

shape_contact_processing_threshold

$physics.shape_contact_processing_threshold(object: Reference, threshold: float)

Set the shape's contact processing threshold for this frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
thresholdfloatThe contact processing threshold.

shape_damping

$physics.shape_damping(object: Reference, linear_damping: float, angular_damping: float)

Set the linear and angular damping on a shape.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
linear_dampingfloatThe linear damping.
angular_dampingfloatThe angular damping.

shape_deactivation_time

$physics.shape_deactivation_time(object: Reference, deactivation_time: float)

Set the shape's deactivation time, which determines how it deactivates in the world.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
deactivation_timefloatDeactivation time.

shape_disable_gravity

$physics.shape_disable_gravity(object: Reference, disable_gravity: bool)

Whether gravity will be disabled on a shape for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
disable_gravityboolWhether the object will be affected by gravity

shape_dynamics

$physics.shape_dynamics(object: Reference, dynamics: int)

Set the dynamics type on a shape for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
dynamicsintThe object dynamics type.

shape_finalize

$physics.shape_finalize(object: Reference, clone_to_visual_world: bool)

Finalize the given shape for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
clone_to_visual_worldboolWhether to clone to visual world. True if unspecified.

shape_force

$physics.shape_force(object: Reference, force: vec3, torque: vec3)

Applies force to a shape.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
forcevec3Force to apply in Newtons
torquevec3Torque to apply in Newtons

shape_get_is_trigger

read-only
$physics.shape_get_is_trigger(object: Reference) -> bool

Get if this object is a trigger.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.

Returns bool: Returns true if a shape is a trigger

shape_impulse

$physics.shape_impulse(object: Reference, force: vec3, torque: vec3)

Applies impulse to a shape.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
forcevec3Impulse to apply in Newtons
torquevec3Torque to apply in Newtons

shape_is_trigger

$physics.shape_is_trigger(object: Reference, is_trigger: bool)

Set if this object is a trigger.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
is_triggerboolWhether the object is a trigger

shape_linear_velocity

$physics.shape_linear_velocity(object: Reference, velocity: vec3)

Set linear velocity on a shape for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
velocityvec3The friction to apply

shape_mass

$physics.shape_mass(object: Reference, mass: float)

Set the mass of a shape. Also update the shape's moment of inertia based on its size and mass.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
massfloatThe mass.

shape_material

$physics.shape_material(object: Reference, material: Reference)

Set physics material for the current frame.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
materialReferenceThe material to apply.

shape_previous_transform

$physics.shape_previous_transform(object: Reference, position: vec3, rotation: vec4)

Set the shape's previous position and rotation, for the purpose of updating a kinematic object's velocity.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
positionvec3The position.
rotationvec4The rotation.

shape_rotational_inertia

$physics.shape_rotational_inertia(object: Reference, inertia: vec3)

Set the moment of inertia of a shape, independent of mass. See btCollisionShape::calculateLocalInertia for how inertia is determined by default.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
inertiavec3The local moment of inertia about each axis.

shape_user_index

$physics.shape_user_index(object: Reference, user_index: int)

Set the shape's user index, which is arbitrary data.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
user_indexintThe user index.

shape_was_created_this_frame

$physics.shape_was_created_this_frame(object: Reference) -> bool

Returns if the shape was created on this exact frame, useful for doing first time setup logic.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.

Returns bool: True if it was created on this frame.

simple_physics_bones_enabled

$physics.simple_physics_bones_enabled() -> bool

Whether to use simple physics bones if available

Returns bool: Returns true if simple physics bones is enabled, false otherwise.

sphere_cast

$physics.sphere_cast(start_pos: vec3, end_pos: vec3, radius: float, collision_info: Reference, visuals_world: bool) -> Reference

Performs a sphere swept convex cast from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
radiusfloatRadius of the sphere.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

sphere_cast_all

$physics.sphere_cast_all(start_pos: vec3, end_pos: vec3, radius: float, collision_info: Reference, visuals_world: bool) -> list

Performs a sphere swept convex cast from the start position to the end position

ParameterTypeMeaning
start_posvec3Where the ray will start.
end_posvec3Where the ray will end.
radiusfloatRadius of the sphere.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns list: Handle to a list of all objects hit

sphere_cast_all_multi

$physics.sphere_cast_all_multi(positions: list, radius: float, collision_info: Reference, visuals_world: bool) -> Reference

Casts a sphere through the given positions (Hit Fraction is per segment rather than the complete ray).

ParameterTypeMeaning
positionslistWhere the ray will start.
radiusfloatradius of the sphere.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to a list of all objects hit

sphere_cast_multi

$physics.sphere_cast_multi(positions: list, radius: float, collision_info: Reference, visuals_world: bool) -> Reference

Casts a sphere through the given positions (Hit Fraction is per segment rather than the complete ray).

ParameterTypeMeaning
positionslistWhere the ray will start.
radiusfloatRadius of the sphere.
collision_infoReferenceCollision layers file.
visuals_worldboolPerform raycast to 'visuals' world only.

Returns Reference: Handle to the first object hit

sphere_from_world

$physics.sphere_from_world(p0: vec3, radius: float, mass: float) -> Reference

Declare a physical sphere for this frame.

ParameterTypeMeaning
p0vec3The initial sphere location offset.
radiusfloatThe sphere radius offset.
massfloatThe sphere mass.

Returns Reference: Handle to a physics sphere.

static_plane_from_world

$physics.static_plane_from_world(p0: vec3, normal: vec3) -> Reference

Declare a physical static infinite plane for this frame.

ParameterTypeMeaning
p0vec3The plane location offset.
normalvec3The normal of the plane.

Returns Reference: Handle to a physics plane.

update

$physics.update(delta_time: float)

Run the physics update.

ParameterTypeMeaning
delta_timefloatThe delta time

vehicle_from_world

$physics.vehicle_from_world(object: Reference, collision_info: Reference) -> Reference

Creates a physics vehicle from shape.

ParameterTypeMeaning
objectReferenceHandle to a physics shape.
collision_infoReferenceCollision layers file.

Returns Reference: Handle to the vehicle.

vehicle_get_number_of_wheels_in_contact

read-only
$physics.vehicle_get_number_of_wheels_in_contact(vehicle: Reference) -> int

Get the number of wheels of a vehicle that are in contact with a collision surface.

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.

Returns int: The number of wheels.

vehicle_get_speed

$physics.vehicle_get_speed(vehicle: Reference) -> float

Creates a physics vehicle from shape.

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.

Returns float: vehicle speed.

vehicle_get_suspension_force

read-only
$physics.vehicle_get_suspension_force(vehicle: Reference) -> float

Get the max current suspension force across all wheels. This force may be larger than the max_suspension_force set using with_max_suspension_travel; it is the force before it is limited.

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.

Returns float: The suspension force.

vehicle_get_wheel_suspension_force

read-only
$physics.vehicle_get_wheel_suspension_force(vehicle: Reference, wheel_index: int) -> float

Get the current suspension force at the given wheel. This force may be larger than the max_suspension_force set using with_max_suspension_travel; it is the force before it is limited.

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
wheel_indexintThe index of the wheel. Wheels are added in the order [front left, front right, back left, back right].

Returns float: The suspension force.

vehicle_is_wheel_in_contact

read-only
$physics.vehicle_is_wheel_in_contact(vehicle: Reference, wheel_index: int) -> bool

Get whether a specified wheel of a vehicle is in contact with a collision surface.

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
wheel_indexintThe index of the wheel. Wheels are added in the order [front left, front right, back left, back right].

Returns bool: Whether the wheel is in contact.

vehicle_set_accelerator

$physics.vehicle_set_accelerator(vehicle: Reference, gas_pedal: float)

set the value of gas pedal

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
gas_pedalfloatThe gas pedal value.

vehicle_set_brake

$physics.vehicle_set_brake(vehicle: Reference, brake_pedal: float)

set the value of brake pedal

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
brake_pedalfloatThe brake pedal value.

vehicle_set_dimensions

$physics.vehicle_set_dimensions(vehicle: Reference, wheelbase: float, axle_width: float, connection_height: float, offset_translation: vec3, offset_rotation: vec4)

Sets the positions of wheels.

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
wheelbasefloatThe wheelbase.
axle_widthfloatThe axle width.
connection_heightfloatThe connection height
offset_translationvec3Offset of the wheel base along the local x axis (forward).
offset_rotationvec4Angle about the local up axis to rotate all wheels relative to the chassis.

vehicle_set_friction_slip

$physics.vehicle_set_friction_slip(vehicle: Reference, value: float)

set the friction slip (higher=less slip)

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe friction slip.

vehicle_set_max_suspension_travel

$physics.vehicle_set_max_suspension_travel(vehicle: Reference, value: float, max_suspension_force: float)

set the max suspension travel in cm

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe max suspension travel incm.
max_suspension_forcefloatThe maximum force that can be applied by the suspension at this wheel.

vehicle_set_roll_influence

$physics.vehicle_set_roll_influence(vehicle: Reference, value: float)

set the roll influence (0=least roll)

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe roll influence.

vehicle_set_steering

$physics.vehicle_set_steering(vehicle: Reference, steering: float)

Turn front wheels of vehicle

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
steeringfloatThe steering value.

vehicle_set_suspension_compression

$physics.vehicle_set_suspension_compression(vehicle: Reference, value: float)

set the suspension compression

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe suspension compression.

vehicle_set_suspension_relaxation

$physics.vehicle_set_suspension_relaxation(vehicle: Reference, value: float)

set the suspension relaxation

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe suspension relaxation

vehicle_set_suspension_rest_length

$physics.vehicle_set_suspension_rest_length(vehicle: Reference, value: float)

set the suspension rest length in cm

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe suspension rest length in cm.

vehicle_set_suspension_stiffness

$physics.vehicle_set_suspension_stiffness(vehicle: Reference, value: float)

set the suspension stiffness

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe suspension stiffness.

vehicle_set_target_speed

$physics.vehicle_set_target_speed(vehicle: Reference, target_speed: float)

set the speed we want vehicle to aim for

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
target_speedfloatthe target speed of vehicle

vehicle_set_wheel_radius

$physics.vehicle_set_wheel_radius(vehicle: Reference, value: float)

set the wheel's radius in cm

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe radius of the wheel in cm.

vehicle_set_wheel_width

$physics.vehicle_set_wheel_width(vehicle: Reference, value: float)

set the wheel's width in cm

ParameterTypeMeaning
vehicleReferenceHandle to a vehicle.
valuefloatThe width of the wheel in cm.

wait

read-only
$physics.wait()

Notify the game that the calling component is done writing to physics. Then waits for physics to complete.

Compiler helpers

The engine marks these as emitted by its own compiler. Most have shorthand in this language; prefer it where the guide shows one. Some are still the only way to do something, and the cookbook uses those deliberately.

set_margins

compiler helper
$physics.set_margins(broadphase_margin: float, contact_threshold: float)

Set the amount which physics shape sizes are expanded during collision resolution. Do not use without consulting a knowledgeable programmer.

ParameterTypeMeaning
broadphase_marginfloatMargin during broadphase bucketing (default 5cm).
contact_thresholdfloatMargin during contact resolution (default 2cm).