Physics
Look up physics calls and properties.
physics.resolve_camera_collision(target, desired)
Adjust a desired camera position for collision.
- Arguments
targetanddesired: three-number position baskets.- Returns
A three-number position basket.
- Works with
Gameplay camera collision geometry.
- Missing values and errors
Wrong counts, types, or basket lengths report an error. Apply the result yourself.
const actual = physics.resolve_camera_collision([0, 1, 0], [0, 3, 5])
camera.set_position(actual)entity.physics.entity
Read the owning Entity.
- Arguments
No call arguments. Read this property.
- Returns
Entity handle. Read-only.
- Works with
entity.physics handles.
- Missing values and errors
Assigning to this property is not supported. Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.entity)
}entity.physics.kind
Read the capability kind.
- Arguments
No call arguments. Read this property.
- Returns
string. Read-only.
- Works with
entity.physics handles.
- Missing values and errors
Assigning to this property is not supported. Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.kind)
}entity.physics.grounded
Read whether the body is grounded.
- Arguments
No call arguments. Read this property.
- Returns
bool. Read-only.
- Works with
entity.physics handles.
- Missing values and errors
Assigning to this property is not supported. Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.grounded)
}entity.physics.enabled
Enable or disable body simulation.
- Arguments
No call arguments. Assign bool to change it.
- Returns
bool. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.enabled)
}entity.physics.solid
Choose whether the body blocks movement.
- Arguments
No call arguments. Assign bool to change it.
- Returns
bool. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.solid)
}entity.physics.anchored
Choose whether the body is fixed.
- Arguments
No call arguments. Assign bool to change it.
- Returns
bool. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.anchored)
}entity.physics.collision_enabled
Enable or disable body collision.
- Arguments
No call arguments. Assign bool to change it.
- Returns
bool. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.collision_enabled)
}entity.physics.mass
Set body mass.
- Arguments
No call arguments. Assign number to change it.
- Returns
number. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.mass)
}entity.physics.velocity
Read or change body velocity.
- Arguments
No call arguments. Assign [x, y, z] numbers to change it.
- Returns
[x, y, z] numbers. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.velocity)
}entity.physics.gravity_scale
Scale gravity for this body.
- Arguments
No call arguments. Assign number to change it.
- Returns
number. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.gravity_scale)
}entity.physics.size
Read or change collider dimensions.
- Arguments
No call arguments. Assign [x, y, z] positive numbers to change it.
- Returns
[x, y, z] positive numbers. Readable and writable.
- Works with
entity.physics handles.
- Missing values and errors
Removed objects and unsupported handle kinds cannot supply this property.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.size)
}entity.physics.is_valid()
Check whether the owning Entity exists.
- Arguments
No arguments.
- Returns
bool.
- Works with
EntityPhysics handles.
- Missing values and errors
Use a valid handle. Wrong argument counts or types report an error.
const enemy = get_entity("Goblin")
if enemy != nil {
debug.log(enemy.physics.is_valid())
}entity.physics.apply_force(force)
Apply a force to the body.
- Arguments
One three-number basket.
- Returns
nil.
- Works with
EntityPhysics handles.
- Missing values and errors
Use a valid handle. Wrong argument counts or types report an error.
const enemy = get_entity("Goblin")
if enemy != nil {
enemy.physics.apply_force([1, 0, 0])
}entity.physics.apply_impulse(impulse)
Apply an immediate impulse.
- Arguments
One three-number basket.
- Returns
nil.
- Works with
EntityPhysics handles.
- Missing values and errors
Use a valid handle. Wrong argument counts or types report an error.
const enemy = get_entity("Goblin")
if enemy != nil {
enemy.physics.apply_impulse([0, 5, 0])
}entity.physics.stop()
Stop the body movement.
- Arguments
No arguments.
- Returns
nil.
- Works with
EntityPhysics handles.
- Missing values and errors
Use a valid handle. Wrong argument counts or types report an error.
const enemy = get_entity("Goblin")
if enemy != nil {
enemy.physics.stop()
}entity.physics.wake()
Wake a sleeping body.
- Arguments
No arguments.
- Returns
nil.
- Works with
EntityPhysics handles.
- Missing values and errors
Use a valid handle. Wrong argument counts or types report an error.
const enemy = get_entity("Goblin")
if enemy != nil {
enemy.physics.wake()
}[BETA] marks features newer than the current public release. Current release: 0.8.0.