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 ).
$ 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.
Parameter Type Meaning 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.
$ physics . arbitrary_mesh_from_world (mesh: Reference , p0: vec3 ) -> Reference
Declare a physical arbitrary mesh for this frame.
Parameter Type Meaning meshReferenceThe mesh to create the physics shape from. p0vec3The initial mesh location offset.
Returns Reference: Handle to a physics convex mesh.
$ 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.
Parameter Type Meaning bindingReferenceThe physics bones binding.
Returns bool: Whether physics shapes have been created for a physics_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.
Parameter Type Meaning 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.
$ physics . bones (bones_data: Reference , collision_group: Reference , collision_layer: Reference , restart_id: int ) -> Reference
Creates physics bones.
Parameter Type Meaning 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.
$ physics . bones_get_root_position (binding: Reference , fallback_position: vec3 ) -> vec3
Gets root position of the physics bone set.
Parameter Type Meaning 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.
$ physics . bones_get_root_rotation (binding: Reference ) -> vec4
Gets root rotation of the physics bones set.
Parameter Type Meaning bindingReferenceThe physics bones binding.
Returns vec4: Root bone rotation.
$ physics . bones_get_shape_by_index (binding: Reference , index: int ) -> Reference
Gets the physics shape by shape index in physics bones
Parameter Type Meaning bindingReferenceThe physics bones binding. indexintThe index
Returns Reference: Physics (shape) bone.
$ 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.
$ physics . box_from_world (p0: vec3 , size: vec3 , mass: float ) -> Reference
Declare a physical box for this frame.
Parameter Type Meaning p0vec3The initial box position offset. sizevec3The box size offset. massfloatThe box mass.
Returns Reference: Handle to a physics box.
$ 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
Parameter Type Meaning 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
$ 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
Parameter Type Meaning 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
$ 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).
Parameter Type Meaning 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
$ 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).
Parameter Type Meaning 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
$ physics . capsule_from_world (p0: vec3 , height: float , radius: float , mass: float ) -> Reference
Declare a physical capsule for this frame.
Parameter Type Meaning p0vec3The initial capsule location offset. heightfloatThe capsule height. radiusfloatThe capsule radius. massfloatThe capsule mass.
Returns Reference: Handle to a physics capsule.
$ physics . carpg_set_collision_params (player_collision_group: Reference , ai_collision_group: Reference , collision_roll_factor: float )
Set carpg project custom collision parameters.
Parameter Type Meaning 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.
$ physics . compound_group_from_world (compound_group: Reference , p0: vec3 ) -> Reference
Declare a physical arbitrary mesh for this frame.
Parameter Type Meaning compound_groupReferenceThe mesh to create the physics shape from. p0vec3The initial mesh location offset.
Returns Reference: Handle to a physics convex mesh.
$ physics . cone_from_world (p0: vec3 , height: float , radius: float , mass: float ) -> Reference
Declare a physical cone for this frame.
Parameter Type Meaning p0vec3The initial cone location offset. heightfloatThe cone height. radiusfloatThe cone radius. massfloatThe cone mass.
Returns Reference: Handle to a physics cone.
$ 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.
Parameter Type Meaning 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.
$ 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.
Parameter Type Meaning 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.
$ physics . constraint_enable_spring (constraint: Reference , axis_mask: int )
enables the spring on a 6dof constraint.
Parameter Type Meaning constraintReferenceHandle to a 6dof physics constraint. axis_maskintThe axis mask.
$ 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.
Parameter Type Meaning 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.
$ physics . constraint_set_damping (constraint: Reference , angular_damping: vec3 , linear_damping: vec3 )
set the damping on a 6dof constraint.
Parameter Type Meaning constraintReferenceHandle to a 6dof physics constraint. angular_dampingvec3The angular damping to apply. linear_dampingvec3The linear damping to apply.
$ 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.
Parameter Type Meaning 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.
$ 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.
Parameter Type Meaning 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.
$ physics . constraint_set_stiffness (constraint: Reference , angular_stiffness: vec3 , linear_stiffness: vec3 )
set the stiffness on a 6dof constraint.
Parameter Type Meaning constraintReferenceHandle to a 6dof physics constraint. angular_stiffnessvec3The angular stiffness to apply. linear_stiffnessvec3The linear stiffness to apply.
$ physics . convex_mesh_from_world (mesh: Reference , p0: vec3 , mass: float ) -> Reference
Declare a physical convex mesh for this frame.
Parameter Type Meaning meshReferenceThe mesh to create the physics shape from. p0vec3The initial mesh location offset. massfloatThe mesh mass.
Returns Reference: Handle to a physics convex mesh.
$ 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
Parameter Type Meaning 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
$ 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
Parameter Type Meaning 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
$ physics . cylinder_from_world (p0: vec3 , size: vec2 , mass: float ) -> Reference
Declare a physical cylinder for this frame.
Parameter Type Meaning p0vec3The initial cylinder position offset. sizevec2The cylinder extents. massfloatThe cylinder mass.
Returns Reference: Handle to a physics cylinder.
$ physics . get_activation_state (object: Reference ) -> int
Set the shape's activation state, which determines how it behaves in the world.
Parameter Type Meaning objectReferenceHandle to a physics shape.
Returns int: Activation state of physics object.
$ physics . get_angular_velocity (object: Reference ) -> vec3
Get the angular velocity of a physics object.
Parameter Type Meaning objectReferenceHandle to a physics object.
Returns vec3: Velocity of physics object.
$ physics . get_closest_bone_index_to_position (binding: Reference , position: vec3 ) -> int
Gets the closest physics bone to the given world position.
Parameter Type Meaning bindingReferenceThe physics bones binding. positionvec3The world position to check against.
Returns int: Physics (shape) bone index, or -1 if no shape available.
$ physics . get_closest_bone_to_position (binding: Reference , position: vec3 ) -> Reference
Gets the closest physics bone to the given world position.
Parameter Type Meaning bindingReferenceThe physics bones binding. positionvec3The world position to check against.
Returns Reference: Physics (shape) bone.
$ physics . get_collision_info (component: Component ) -> Reference
Get a handle to the collision info for this shape.
Parameter Type Meaning componentComponentThe component to get the collision info handle from.
Returns Reference: Handle to the shapes collision info.
$ 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.
Parameter Type Meaning infoReferenceHandle to a shapes collision info. indexintIndex into the collision info.
Returns float: The magnitude of applied impulse
$ 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.
Parameter Type Meaning infoReferenceHandle to a shapes collision info. indexintIndex into the collision info.
Returns Component: Handle to a component that collided, or null if none.
$ physics . get_collision_info_count (info: Reference ) -> int
Get the count of collisions for the given collision handle.
Parameter Type Meaning infoReferenceHandle to a shapes collision info.
Returns int: The count of collisions.
$ physics . get_collision_info_normal (info: Reference , index: int ) -> vec3
Get the physics normal at the given index from the given collision info.
Parameter Type Meaning infoReferenceHandle to a shapes collision info. indexintIndex into the collision info.
Returns vec3: The normal of the collided object.
$ physics . get_collision_info_position (info: Reference , index: int ) -> vec3
Get the physics normal at the given index from the given collision info.
Parameter Type Meaning infoReferenceHandle to a shapes collision info. indexintIndex into the collision info.
Returns vec3: The position of the collided object.
$ physics . get_collision_info_shape (info: Reference , index: int ) -> Reference
Get the physics shape at the given index from the given collision info.
Parameter Type Meaning infoReferenceHandle to a shapes collision info. indexintIndex into the collision info.
Returns Reference: Handle to a shape that collided, or null if none.
$ 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.
Parameter Type Meaning infoReferenceHandle to a shapes collision info. indexintIndex into the collision info.
Returns int: User index of shape (or sub-shape).
$ physics . get_component_shape (component: Component ) -> Reference
Get a handle to the shape created by this component.
Parameter Type Meaning componentComponentThe component.
Returns Reference: Handle to the shape.
$ physics . get_deactivation_time (object: Reference ) -> float
Set the shape's deactivation time, which determines how it deactivates in the world.
Parameter Type Meaning objectReferenceHandle to a physics shape.
Returns float: Deactivation time of physics object.
$ physics . get_gravity () -> vec3
Get the gravity of the physics world.
Returns vec3: The current value of gravity.
$ 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.
$ physics . get_linear_velocity (object: Reference ) -> vec3
Get the linear velocity of a physics object.
Parameter Type Meaning objectReferenceHandle to a physics object.
Returns vec3: Velocity of physics object.
$ physics . get_position (object: Reference ) -> vec3
Get the position a physical sphere.
Parameter Type Meaning objectReferenceHandle to a physics object.
Returns vec3: Position of physics object.
$ physics . get_raycast_info_component (info: Reference ) -> Component
Get the physics component on the object from the given raycast hit info.
Parameter Type Meaning infoReferenceHandle to a raycast hit info.
Returns Component: Handle to a raycast hit component.
$ 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.
Parameter Type Meaning infoReferenceHandle to a raycast hit info.
Returns float: The object hit fraction along the ray.
$ physics . get_raycast_info_normal (info: Reference ) -> vec3
Get the hit normal from the given raycast hit info.
Parameter Type Meaning infoReferenceHandle to a raycast hit info.
Returns vec3: The raycast hit normal
$ physics . get_raycast_info_position (info: Reference ) -> vec3
Get the hit position from the given raycast hit info.
Parameter Type Meaning infoReferenceHandle to a raycast hit info.
Returns vec3: The raycast hit position
$ physics . get_raycast_info_shape (info: Reference ) -> Reference
Returns the (opaque) physics shape hit by a ray.
Parameter Type Meaning infoReferenceHandle to a raycast hit info.
Returns Reference: Handle to the physics shape hit by the ray.
$ physics . get_raycast_info_user_index (info: Reference ) -> int
Returns the user_index for the shape hit by a ray.
Parameter Type Meaning infoReferenceHandle to a raycast hit info.
Returns int: The user index of the shape hit by the ray..
$ physics . get_rotation (object: Reference ) -> vec4
Get the rotation a physical sphere.
Parameter Type Meaning objectReferenceHandle to a physics object.
Returns vec4: Rotation of physics object.
$ 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 . physics_bones_disable_gravity (binding: Reference , state: bool )
Whether gravity will be disabled on a set of physics bones for the current frame.
Parameter Type Meaning bindingReferenceThe physics bones binding. stateboolThe force to apply.
$ 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
Parameter Type Meaning 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
$ 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
Parameter Type Meaning 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
$ 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).
Parameter Type Meaning 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
$ 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).
Parameter Type Meaning positionslistWhere the ray will start. collision_infoReferenceCollision layers file. visuals_worldboolPerform raycast to 'visuals' world only.
Returns Reference: Handle to the first object hit
$ physics . set_gravity (gravity: vec3 )
Set the gravity of the physics world.
Parameter Type Meaning gravityvec3Value to set the physics world gravity to.
$ physics . set_visuals_collision_mask (collision_mask: Reference )
Set the collision mask for the visuals world.
Parameter Type Meaning collision_maskReferenceCollision layers file.
$ physics . set_world_scale (scale: float )
Set the scale of the physics world relative to the engine (e.g. cm->m)
Parameter Type Meaning scalefloatValue to set the physics world scale to.
$ physics . shape_activation_state (object: Reference , activation_state: int )
Set the shape's activation state, which determines how it behaves in the world.
Parameter Type Meaning objectReferenceHandle to a physics shape. activation_stateintActivation state.
$ physics . shape_allow_rotation (object: Reference , allow_rotation: bool )
Set if this object can rotate from external forces.
Parameter Type Meaning objectReferenceHandle to a physics shape. allow_rotationboolWhether the object is allowed to rotate from external forces
$ 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.
Parameter Type Meaning objectReferenceHandle to a physics shape. angular_factorvec3The angular factor.
$ physics . shape_angular_velocity (object: Reference , velocity: vec3 )
Set angular velocity on a shape for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. velocityvec3The friction to apply
$ physics . shape_ccd_motion_threshold (object: Reference , motion_threshold: float )
Set the motion threshold on a shape for continuous collision detection.
Parameter Type Meaning objectReferenceHandle to a physics shape. motion_thresholdfloatThe motion threshold.
$ physics . shape_ccd_swept_sphere_radius (object: Reference , radius: float )
Set the swept sphere radius on a shape for continuous collision detection .
Parameter Type Meaning objectReferenceHandle to a physics shape. radiusfloatThe swept sphere radius.
$ physics . shape_collision_group (object: Reference , collision_info: Reference )
Set the given shapes collision group for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. collision_infoReferenceCollision group file.
$ physics . shape_collision_mask (object: Reference , collision_info: Reference )
Set the given shapes collision mask for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. collision_infoReferenceCollision layers file.
$ physics . shape_contact_processing_threshold (object: Reference , threshold: float )
Set the shape's contact processing threshold for this frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. thresholdfloatThe contact processing threshold.
$ physics . shape_damping (object: Reference , linear_damping: float , angular_damping: float )
Set the linear and angular damping on a shape.
Parameter Type Meaning objectReferenceHandle to a physics shape. linear_dampingfloatThe linear damping. angular_dampingfloatThe angular damping.
$ physics . shape_deactivation_time (object: Reference , deactivation_time: float )
Set the shape's deactivation time, which determines how it deactivates in the world.
Parameter Type Meaning objectReferenceHandle to a physics shape. deactivation_timefloatDeactivation time.
$ physics . shape_disable_gravity (object: Reference , disable_gravity: bool )
Whether gravity will be disabled on a shape for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. disable_gravityboolWhether the object will be affected by gravity
$ physics . shape_dynamics (object: Reference , dynamics: int )
Set the dynamics type on a shape for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. dynamicsintThe object dynamics type.
$ physics . shape_finalize (object: Reference , clone_to_visual_world: bool )
Finalize the given shape for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. clone_to_visual_worldboolWhether to clone to visual world. True if unspecified.
$ physics . shape_force (object: Reference , force: vec3 , torque: vec3 )
Applies force to a shape.
Parameter Type Meaning objectReferenceHandle to a physics shape. forcevec3Force to apply in Newtons torquevec3Torque to apply in Newtons
$ physics . shape_get_is_trigger (object: Reference ) -> bool
Get if this object is a trigger.
Parameter Type Meaning objectReferenceHandle to a physics shape.
Returns bool: Returns true if a shape is a trigger
$ physics . shape_impulse (object: Reference , force: vec3 , torque: vec3 )
Applies impulse to a shape.
Parameter Type Meaning objectReferenceHandle to a physics shape. forcevec3Impulse to apply in Newtons torquevec3Torque to apply in Newtons
$ physics . shape_is_trigger (object: Reference , is_trigger: bool )
Set if this object is a trigger.
Parameter Type Meaning objectReferenceHandle to a physics shape. is_triggerboolWhether the object is a trigger
$ physics . shape_linear_velocity (object: Reference , velocity: vec3 )
Set linear velocity on a shape for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. velocityvec3The friction to apply
$ 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.
Parameter Type Meaning objectReferenceHandle to a physics shape. massfloatThe mass.
$ physics . shape_material (object: Reference , material: Reference )
Set physics material for the current frame.
Parameter Type Meaning objectReferenceHandle to a physics shape. materialReferenceThe material to apply.
$ 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.
Parameter Type Meaning objectReferenceHandle to a physics shape. positionvec3The position. rotationvec4The rotation.
$ 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.
Parameter Type Meaning objectReferenceHandle to a physics shape. inertiavec3The local moment of inertia about each axis.
$ physics . shape_user_index (object: Reference , user_index: int )
Set the shape's user index, which is arbitrary data.
Parameter Type Meaning objectReferenceHandle to a physics shape. user_indexintThe user index.
$ 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.
Parameter Type Meaning objectReferenceHandle to a physics shape.
Returns bool: True if it was created on this frame.
$ 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.
$ 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
Parameter Type Meaning 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
$ 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
Parameter Type Meaning 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
$ 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).
Parameter Type Meaning 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
$ 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).
Parameter Type Meaning 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
$ physics . sphere_from_world (p0: vec3 , radius: float , mass: float ) -> Reference
Declare a physical sphere for this frame.
Parameter Type Meaning p0vec3The initial sphere location offset. radiusfloatThe sphere radius offset. massfloatThe sphere mass.
Returns Reference: Handle to a physics sphere.
$ physics . static_plane_from_world (p0: vec3 , normal: vec3 ) -> Reference
Declare a physical static infinite plane for this frame.
Parameter Type Meaning p0vec3The plane location offset. normalvec3The normal of the plane.
Returns Reference: Handle to a physics plane.
$ physics . update (delta_time: float )
Run the physics update.
Parameter Type Meaning delta_timefloatThe delta time
$ physics . vehicle_from_world (object: Reference , collision_info: Reference ) -> Reference
Creates a physics vehicle from shape.
Parameter Type Meaning objectReferenceHandle to a physics shape. collision_infoReferenceCollision layers file.
Returns Reference: Handle to the vehicle.
$ 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.
Parameter Type Meaning vehicleReferenceHandle to a vehicle.
Returns int: The number of wheels.
$ physics . vehicle_get_speed (vehicle: Reference ) -> float
Creates a physics vehicle from shape.
Parameter Type Meaning vehicleReferenceHandle to a vehicle.
Returns float: vehicle speed.
$ 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.
Parameter Type Meaning vehicleReferenceHandle to a vehicle.
Returns float: The suspension force.
$ 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.
Parameter Type Meaning 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.
$ 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.
Parameter Type Meaning 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.
$ physics . vehicle_set_accelerator (vehicle: Reference , gas_pedal: float )
set the value of gas pedal
Parameter Type Meaning vehicleReferenceHandle to a vehicle. gas_pedalfloatThe gas pedal value.
$ physics . vehicle_set_brake (vehicle: Reference , brake_pedal: float )
set the value of brake pedal
Parameter Type Meaning vehicleReferenceHandle to a vehicle. brake_pedalfloatThe brake pedal value.
$ 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.
Parameter Type Meaning 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.
$ physics . vehicle_set_friction_slip (vehicle: Reference , value: float )
set the friction slip (higher=less slip)
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe friction slip.
$ physics . vehicle_set_max_suspension_travel (vehicle: Reference , value: float , max_suspension_force: float )
set the max suspension travel in cm
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe max suspension travel incm. max_suspension_forcefloatThe maximum force that can be applied by the suspension at this wheel.
$ physics . vehicle_set_roll_influence (vehicle: Reference , value: float )
set the roll influence (0=least roll)
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe roll influence.
$ physics . vehicle_set_steering (vehicle: Reference , steering: float )
Turn front wheels of vehicle
Parameter Type Meaning vehicleReferenceHandle to a vehicle. steeringfloatThe steering value.
$ physics . vehicle_set_suspension_compression (vehicle: Reference , value: float )
set the suspension compression
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe suspension compression.
$ physics . vehicle_set_suspension_relaxation (vehicle: Reference , value: float )
set the suspension relaxation
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe suspension relaxation
$ physics . vehicle_set_suspension_rest_length (vehicle: Reference , value: float )
set the suspension rest length in cm
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe suspension rest length in cm.
$ physics . vehicle_set_suspension_stiffness (vehicle: Reference , value: float )
set the suspension stiffness
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe suspension stiffness.
$ physics . vehicle_set_target_speed (vehicle: Reference , target_speed: float )
set the speed we want vehicle to aim for
Parameter Type Meaning vehicleReferenceHandle to a vehicle. target_speedfloatthe target speed of vehicle
$ physics . vehicle_set_wheel_radius (vehicle: Reference , value: float )
set the wheel's radius in cm
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe radius of the wheel in cm.
$ physics . vehicle_set_wheel_width (vehicle: Reference , value: float )
set the wheel's width in cm
Parameter Type Meaning vehicleReferenceHandle to a vehicle. valuefloatThe width of the wheel in cm.
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.
$ 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.
Parameter Type Meaning broadphase_marginfloatMargin during broadphase bucketing (default 5cm). contact_thresholdfloatMargin during contact resolution (default 2cm).