Physics
Last updated
Last updated
[This feature is still in Open Beta and may have some bugs. Please direct any feedback to the Planetary Processing Team on ]
Physics is an optional server-side setting that can be enabled for entities. When physics is applied to an entity, it is assigned a mass, a body (defining its shape), and a velocity. Forces can be applied to modify an entity’s velocity, and collisions between entities are simulated server-side.
Physics must be enabled on an entity for it to have a and interact in . An entity with physics enabled will not collide with another entity that does not have Physics enabled.
The body can be either a sphere or a box.
Collisions are Elastic: No energy is lost during collisions.
Collision Detection: Collisions are only detected if entities are overlapping during an update.
If the game's ticks per second (TPS) is low and an entity's speed is high, collisions may be missed. To prevent this, ensure:
A higher TPS reduces the risk of undetected collisions and unintended behaviour.
A number of API calls are available for certain physics-related actions, such as creating a physics Body. They are accessed using the api.physics
object available to all server-side scripts.
Methods
Box
width: float
length: float
depth: float
An axis-aligned bounding box.
Sphere
radius: float
It's just a sphere.
Shape
Shape
The size and shape of the Body's collision boundaries.
Mass
float
The mass of the physics body, which dictates how effective forces are upon it.
Force
Vector
The XYZ vector of force being applied to the physics body on the current update.
Velocity
Vector
The current velocity of the physics body, for how fast it is moving in an XYZ direction.
Each of these methods takes the Body object self.Body
as its first parameter. Hence you may use self.Body:ApplyForce(force)
instead of self.Body.ApplyForce(self.Body, force)
.
ApplyForce
force: vector
None
Apply a one time XYZ force to a physics body. It is applied on the next update.
GetBoxDimensions
None
width: float
length: float
depth: float
Get the dimensions of a box shaped Body. Errors if the Body is not a Box.
GetRadius
None
radius: float
Get the radius of a Body. Errors if the Body is not a Sphere.
X
float
Y
float
Z
float
Each of these methods takes the Vector
object as its first parameter. Hence you may use vector_a:Add(vector_b)
instead of vector_a.Add(vector_a,vector_b)
.
Add
b: Vector
Vector
Add the corresponding vector value:
a.X + b.X
a.Y + b.Y
a.Z + b.Z
Sub
b: Vector
Vector
Subtract the corresponding vector value:
a.X - b.X
a.Y - b.Y
a.Z - b.Z
Dot
b: Vector
float
Measure the degree of directional similarity between the parameters:
a.X*b.X
+ a.Y*b.Y
+ a.Z*b.Z
Mul
b: float
Vector
Multiply each vector value by a number:
a.X * b
a.Y * b
a.Z * b
Cross
b: Vector
Vector
Create a third vector, perpendicular to the parameters:
a.Y*b.Z - a.Z*b.Y
a.Z*b.X - a.X*b.Z
a.X*b.Y - a.Y*b.X
Normalize
None
Vector
Make a vector unit length:
mag =
Sqrt(v.X^2
+v.Y^2
+v.Z^2)
norm =
Mul(v, 1/mag)
Magnitude
None
Vector
Calculate the scale of the vector.
mag =
Sqrt(v.X^2
+v.Y^2
+v.Z^2)
Currently rotation is not supported.
Due to synchronization between multiplayer elements, physics is not deterministic. This means that you may experience different physics interactions each time you run a simulation.
The function applies a force to an entity once during a physics update and is then reset immediately afterward. To apply a continuous , you must reapply it each update.
Multiple can be applied within a single update cycle. These are combined and applied together in the next physics update.
The Planetary Processing physics engine currently supports two kinds of 3D : a box or a sphere. are used to define the boundaries for an entity's .
The represents an entity for the game's server-side physics. It defines the entity’s and mass. These attributes determine how the entity interacts with , , and other physics-based calculations.
For physics interactions in 3D space, motion occurs across the X, Y, and Z axes. So it helps to group XYZ values into to represent a single direction, for fields like velocities and .
When two entities with enabled and a intersect, they collide. The physics engine calculates a 3D elastic collision, determining the resulting motion .
To simulate a fixed body, such as a wall, assign it a very high (e.g., 999999). The should be several orders of magnitude larger than other entities that might collide with it. This ensures the remains effectively unchanged during collisions, with all energy transferred to the colliding object.
For absolute certainty that it won’t move, manually set its to 0 every update.
To create an inelastic collision (in which rebound momentum is not conserved), try applying an additional to an object when its changes.
Planetary Processing Physics is in continuous development. Please contact us on our if you would like to request specific functionality.
shape: Shape
mass: float
Body
Create a physics body with a shape and mass capable of collisions.
width: float
length: float
depth: float
Box
An axis-aligned bounding box.
radius: float
Sphere
It's just a sphere.