Actor Physics API
- Sub SetGravity3D(x, y, z)
Sets the world gravity.
- Sub GetGravity3D(ByRef x, ByRef y, ByRef z)
Gets the world gravity
See also
- Sub SetActorShape(actor, shape_type, mass)
Sets the shape of an actor.
Possible Actor Shapes:
- ACTOR_SHAPE_NONE
- ACTOR_SHAPE_BOX
- ACTOR_SHAPE_SPHERE
- ACTOR_SHAPE_CYLINDER
- ACTOR_SHAPE_CAPSULE
- ACTOR_SHAPE_CONE
- ACTOR_SHAPE_CONVEXHULL
- ACTOR_SHAPE_TRIMESH
- ACTOR_SHAPE_COMPOSITE
- ACTOR_SHAPE_IMPACT_MESH
NOTE: ACTOR_SHAPE_COMPOSITE is not a shape you can set. It is a shape that is automatically set on composite actors.
See also
- Function GetActorShape(actor)
Returns the shape of an actor.
Possible Actor Shapes:
- ACTOR_SHAPE_NONE
- ACTOR_SHAPE_BOX
- ACTOR_SHAPE_SPHERE
- ACTOR_SHAPE_CYLINDER
- ACTOR_SHAPE_CAPSULE
- ACTOR_SHAPE_CONE
- ACTOR_SHAPE_CONVEXHULL
- ACTOR_SHAPE_TRIMESH
- ACTOR_SHAPE_COMPOSITE
- ACTOR_SHAPE_IMPACT_MESH
See also
- Sub SetActorSolid(actor, flag)
Sets whether an actor has physics and collision response applied to it.
Note: Collision detection will still work for non solid actors
See also
- Function ActorIsSolid(actor)
Returns true or false depending on if physics and collision response applies to an actor.
Note: Collision is still able to be checked on an actor but the actor will be like a ghost able to go through wall and other objects.
SetActorSolid(actor, true)
Print "Actor solid state: "; ActorIsSolid(actor) 'This will output 1
SetActorSolid(actor, false)
Print "Actor solid state: "; ActorIsSolid(actor) 'This will output 0
#/end
#ref SetActorSolid - Function GetActorCollision(actor1, actor2)
Returns true if 2 actors collide
Note: This function will work with solid and non solid actors.
- Sub SetActorGravity(actor, x, y, z)
Sets the gravity vector of an actor.
See also
- Sub GetActorGravity(actor, ByRef x, ByRef y, ByRef z)
Gets the gravity of an actor along each access.
See also
- Sub SetActorDamping(actor, lin_damping, ang_damping)
Sets the linear and angular damping for an actor
- Function GetActorLinearDamping(actor)
Return’s an actor’s linear damping.
See also
SetActorDamping(),GetActorAngularDamping()
- Function GetActorAngularDamping(actor)
Returns the amount of angular damping set on the actor
See also
SetActorDamping(),ApplyActorDamping(),GetActorLinearDamping()
- Function GetActorLinearSleepThreshold(actor)
Returns the linear deactivation threshold for the actor.
See also
SetActorSleepThresholds(),GetActorAngularSleepThreshold()
- Function GetActorAngularSleepThreshold(actor)
Returns the Angular deactivation threshold for the actor.
See also
SetActorSleepThresholds(),GetActorLinearSleepThreshold()
- Sub ApplyActorDamping(actor, timeStep)
Reduces the velocity of an actor over time, simulating the effect of friction or air resistance.
This function applies the linear and angular damping values set with the SetActorDamping() function.
init_damping = False
SetActorDamping(actor, 0.1, 0.5)
ApplyActorCentralImpulse(actor, 300, 0, 0)
While True
If Not init_damping Then
ApplyActorDamping(actor, 5.0) 'Will apply the damping effect for 5 seconds
init_damping = True
End If
Update()
WendSee also
SetActorDamping(),GetActorLinearDamping(),GetActorAngularDamping()
- Function SetActorMassProperties(actor, mass, inertia_x, inertia_y, inertia_z)
Set the mass and local inertia of an actor. This is crucial for defining how the actor behaves under the influence of forces and torques, especially when it comes to simulating realistic motion and rotation.
Mass:
- The mass of an actor defines how much it resists changes in its motion when forces are applied. A heavier object will require more force to accelerate or decelerate compared to a lighter object
Inertial
- The local inertia is a vector that represents how the mass is distributed within the actor relative to its center of mass. It affects how the actor resists rotational forces (torques). An object with a larger inertia value along a specific axis will rotate more slowly when a torque is applied in that direction, and vice versa.
- Sub GetActorLinearFactor(actor, ByRef x, ByRef y, ByRef z)
Gets an actor’s linear factor.
- Sub SetActorLinearFactor(actor, x, y, z)
Sets an actor's linear factor.
The linear factor determines how the actor responds to linear velocity or force.
See also
GetActorLinearFactor(),SetActorAngularFactor(),GetActorAngularFactor()
- Function GetActorInverseMass(actor)
Returns an actor's inverse mass.
See also
- Sub IntegrateActorVelocities(actor, v_step)
Updates the linear and angular velocities of an actor based on the forces and torques applied to it over a time step.
Note: This is more manual control than most devs will probably need
- Sub ApplyActorCentralForceLocal(actor, x, y, z)
Applies a force to the center of mass of an actor in local coordinate space. This force impacts the linear velocity of the object without affecting its rotation.
x,y,z - direction of the force
- Sub ApplyActorCentralForceWorld(actor, x, y, z)
Applies a force to the center of mass of an actor in world coordinate space. This force impacts the linear velocity of the object without affecting its rotation. x,y,z - direction of the force
- Sub GetActorTotalForce(actor, ByRef x, ByRef y, ByRef z)
Gets the total net force currently acting on an actor. This force is the sum of all external forces applied to the actor at a given point in time, including forces like gravity, applied forces, and other interactions such as contact or collision forces.
See also
- Sub GetActorTotalTorque(actor, ByRef x, ByRef y, ByRef z)
Gets the total net torque currently acting on an actor. Torque represents the rotational equivalent of force, describing how different forces applied to the actor cause it to rotate. The total torque is the sum of all external torques acting on the actor, which determine how the actor will rotate or change its angular velocity.
See also
GetTotalForces()
- Sub SetActorInverseInertiaDiagLocal(actor, x, y, z)
Sets the inverse of the inertia tensor’s diagonal components in an actor’s local space. This is used to compute how the actor reacts to rotational forces (torques) applied to it.
See also
GetActorInverseInertiaDiagLocal()
- Sub GetActorInverseInertiaDiagLocal(actor, ByRef x, ByRef y, ByRef z)
Gets the inverse of the inertia tensor’s diagonal components in the local space. This is used to compute how the actor reacts to rotational forces (torques) applied to it.
- Sub SetActorSleepThresholds(actor, linear, angular)
Sets the linear and angular deactivation thresholds for an actor
- Sub ApplyActorTorqueLocal(actor, x, y, z)
Applies a continuous torque to an actor, causing it to accelerate its rotational motion over time. Unlike applyActorTorqueImpulse, which causes an immediate change in angular velocity, this applies a torque force gradually, leading to a continuous rotational effect, similar to applying a force to linear motion.
x, y, z - direction of rotation
- Sub ApplyActorTorqueWorld(actor, x, y, z)
Applies a continuous torque to an actor, causing it to accelerate its rotational motion over time. Unlike applyActorTorqueImpulse, which causes an immediate change in angular velocity, this applies a torque force gradually, leading to a continuous rotational effect, similar to applying a force to linear motion.
x, y, z - direction of rotation
- Sub ApplyActorForceLocal(actor, x, y, z, rel_x, rel_y, rel_z)
Applies a force to an actor at a specific point. Unlike ApplyActorCentralForce(local/world), which applies force only at the center of mass (affecting linear velocity), this can generate both linear motion and rotation (torque), depending on where the force is applied relative to the center of mass.
x,y,z - direction of the force rel_x, rel_y, rel_z - position to apply the force to relative to the
- Sub ApplyActorForceWorld(actor, x, y, z, rel_x, rel_y, rel_z)
Applies a force to an actor at a specific point. Unlike ApplyActorCentralForce(local/world), which applies force only at the center of mass (affecting linear velocity), this can generate both linear motion and rotation (torque), depending on where the force is applied relative to the center of mass.
x,y,z - direction of the force rel_x, rel_y, rel_z - position to apply the force to relative to the
- Sub ApplyActorCentralImpulseLocal(actor, x, y, z)
Applies an impulse directly to the center of mass of an actor. An impulse differs from a continuous force in that it applies an immediate, short-duration change to the velocity of the actor. It affects the linear velocity but does not generate rotational effects (since it’s applied to the center of mass).
x,y,z - direction of the impulse
- Sub ApplyActorCentralImpulseWorld(actor, x, y, z)
Applies an impulse directly to the center of mass of an actor. An impulse differs from a continuous force in that it applies an immediate, short-duration change to the velocity of the actor. It affects the linear velocity but does not generate rotational effects (since it’s applied to the center of mass).
x,y,z - direction of the impulse
- Sub ApplyActorTorqueImpulseLocal(actor, x, y, z)
Applies an impulse that directly affects the angular velocity of an actor, causing it to rotate. This is similar to applying an impulse, but instead of changing the linear velocity (which applyActorCentralImpulse does), it alters the body’s rotational motion (angular velocity) instantaneously.
x, y, z - Direction of rotation
See also
ApplyActorTorque(),ApplyActorTorqueImpulseWorld()
- Sub ApplyActorTorqueImpulseWorld(actor, x, y, z)
Applies an impulse that directly affects the angular velocity of an actor, causing it to rotate. This is similar to applying an impulse, but instead of changing the linear velocity (which applyActorCentralImpulse does), it alters the body’s rotational motion (angular velocity) instantaneously.
x, y, z - Direction of rotation
See also
ApplyActorTorque(),ApplyActorTorqueImpulseLocal()
- Sub ApplyActorImpulseLocal(actor, x, y, z, rel_x, rel_y, rel_z)
Applies an impulse to an actor at a specific point. Unlike ApplyActorCentralImpulse(local/world), which applies impulse only at the center of mass (affecting linear velocity), this can generate both linear motion and rotation (torque), depending on where the force is applied relative to the center of mass.
x,y,z - direction of the impulse rel_x, rel_y, rel_z - position to apply the force to relati
- Sub ApplyActorImpulseWorld(actor, x, y, z, rel_x, rel_y, rel_z)
Applies an impulse to an actor at a specific point. Unlike ApplyActorCentralImpulse(local/world), which applies impulse only at the center of mass (affecting linear velocity), this can generate both linear motion and rotation (torque), depending on where the force is applied relative to the center of mass.
x,y,z - direction of the impulse rel_x, rel_y, rel_z - position to apply the force to relati
- Sub ClearActorForces(actor)
Resets or clears all the forces and torques that have been applied to a rigid body in the current simulation step. This ensures that any forces, including linear forces and torques, do not accumulate from one simulation step to the next.
Notes:
- Resets Forces: It removes all linear forces (like those applied by applyActorForce or applyActorCentralForce) and torques (like those applied by applyActorTorque).
- Does Not Affect Velocity: It clears only the applied forces and torques, but the current velocity (linear and angular) of the actor remains unchanged.
- Typically Used in Each Simulation Step: Used to reset forces after each step, so that only new forces applied in the next step will affect the body.
- Sub UpdateActorInertiaTensor(actor)
Recalculates the inertia tensor of an actor, which is essential for accurately simulating how the actor reacts to forces and torques during its motion. The inertia tensor defines how the mass of the body is distributed in space and influences how the body rotates in response to applied torques.
- Sub GetActorCenter(actor, ByRef x, ByRef y, ByRef z)
Gets an actor’s center of mass position. This is useful for setting the origin of constraints.
- Sub GetActorRotationQ(actor, ByRef x, ByRef y, ByRef z, ByRef w)
Gets the actors rotation as a quaternion.
Note: This is useful for calculations that require quaternion but most developers should just use GetActorTransform()
See also
- Sub GetActorLinearVelocityWorld(actor, ByRef x, ByRef y, ByRef z)
Gets actor’s linear velocity
See also
SetActorLinearVelocityLocal(),SetActorLinearVelocityWorld()
- Sub GetActorAngularVelocityWorld(actor, ByRef x, ByRef y, ByRef z)
Gets an actor’s Angular Velocity
See also
GetActorAngularVelocityLocal(),SetActorAngularVelocityLocal(),SetActorAngularVelocityWorld()
- Sub SetActorLinearVelocityWorld(actor, x, y, z)
Sets actor’s linear velocity
See also
SetActorLinearVelocityLocal(),GetActorLinearVelocityWorld()
- Sub GetActorAngularVelocityLocal(actor, x, y, z)
Sets an actor’s Angular Velocity
See also
GetActorAngularVelocityWorld(),GetActorAngularVelocityLocal(),SetActorAngularVelocityWorld()
- Sub SetActorAngularVelocityWorld(actor, x, y, z)
Sets an actor’s Angular Velocity
See also
GetActorAngularVelocityWorld(),GetActorAngularVelocityLocal(),SetActorAngularVelocityLocal()
- Sub GetActorVelocityInLocalPoint(actor, rel_x, rel_y, rel_z, ByRef x, ByRef y, ByRef z)
Gets the linear velocity of a specific point on an actor, given its position in the actor’s local coordinate space. This is useful for determining how fast and in what direction a particular point on the actor is moving, accounting for both the body’s linear velocity and its rotational motion (angular velocity).
- Sub GetActorLinearVelocityLocal(actor, ByRef x, ByRef y, ByRef z)
Gets actor’s linear velocity
See also
SetActorLinearVelocityLocal(),SetActorLinearVelocityWorld()
- Sub GetActorAngularVelocityLocal(actor, ByRef x, ByRef y, ByRef z)
Gets an actor’s Angular Velocity
See also
GetActorAngularVelocityWorld(),SetActorAngularVelocityLocal(),SetActorAngularVelocityWorld()
- Sub GetActorAABB(actor, ByRef min_x, ByRef min_y, ByRef min_z, ByRef max_x, ByRef max_y, ByRef max_z)
Gets the bounding box for an actor.
- Function ComputeActorImpulseDenominator(actor, pos_x, pos_y, normal_x, normal_y, normal_z)
Computes a scalar value related to how a rigid body will respond to an applied impulse at a given point. It’s primarily used internally in the physics engine to calculate how an object’s mass, inertia, and shape will affect the outcome of impulses, particularly in collisions or constraints like contact points between objects.
- Function ComputeActorAngularImpulseDenominator(actor, x, y, z)
Computes a scalar value that represents how an actor will respond to an angular impulse at a given point, taking into account the actor's inertia tensor (which governs how the object resists rotation). This function is particularly useful in calculating the actor's rotational response to an impulse, typically during collision resolution or constraints involving rotation.
See also
- Sub SetActorAngularFactor(actor, x, y, z)
Sets an actor's angular factor.
The angular factor determines how the actor responds to angular velocity or torque.
- Sub GetActorAngularFactor(actor, x, y, z)
Returns the angular factor set on an actor.
- Sub GetActorAngularFactor(actor, ByRef x, ByRef y, ByRef z)
Sets actor’s linear velocity
See also
SetActorLinearVelocityLocal(),GetActorLinearVelocityWorld()
- Sub ComputeActorGyroImpulseLocal(actor, dt, ByRef x, ByRef y, ByRef z, radius)
Computes the gyroscopic impulse for an actor in an implicit manner, based on the actor's current angular velocity and inertia. This function is used to simulate the gyroscopic effect—also known as gyroscopic precession—which occurs when a rotating object experiences a torque that causes its axis of rotation to change.
See also
- Sub ComputeActorGyroImpulseWorld(actor, dt, ByRef x, ByRef y, ByRef z)
Cast a ray and get the closest hit on the ray Returns 1 if there is a hit and 0 if not NOTE: GetRayHit3D is used to read each hit
See also
- Sub GetActorLocalInertia(actor, ByRef x, ByRef y, ByRef z)
Gets the local inertia tensor of an actor. The inertia tensor describes how an actor resists rotational motion depending on its mass distribution relative to its center of mass.
- Sub SetActorSleepState(actor, state)
- Sub CastRay3D(from_x, from_y, from_z, to_x, to_y, to_z)
Cast a ray and get the closest hit on the ray
Returns 1 if there is a hit and 0 if not
NOTE: GetRayHit3D is used to read each hit
- Function CastRay3D_All(from_x, from_y, from_z, to_x, to_y, to_z)
Cast a ray and gets all hits on the ray
Returns the number of hits from the ray cast
NOTE: GetRayHit3D is used to read each hit
See also
GetRayHit3D(),CastRay3D(),CastRay2D(),CastRay2D_All(),GetRayHit2D()
- Sub GetRayHit3D(index, ByRef actor_id, ByRef x, ByRef y, ByRef z, ByRef normal_x, ByRef normal_y, ByRef normal_z)
This function will get the collision point and the normal of a ray hit.
NOTE:
- CastRay3D or CastRay3D_All must be called prior to calling this function actor_id will return -1 if there was not a hit at the specified index
See also
CastRay3D(),CastRay3D_All(),CastRay2D(),CastRay2D_All(),GetRayHit2D()
- Sub SetActorShapeEx(actor, shape_type, mass, radius)
Sets actor shape and radius for capsule, cone, and sphere shapes.
See also
- Sub SetActorImpactMesh(actor, mesh, mass)
Sets the collision mesh for an actor with a shape type of ACTOR_SHAPE_IMPACT_MESH.
See also