Physics
Category
Category:All -> categories
The set of all categories defined using with category
keyword.
Category:None -> categories
An empty set of categories.
Category:Tangible -> categories
The set of all categories declared with tangible category
.
This is useful to make exceptions to the tangible category.
Examples:
To collide with any tangible colliders or grabbable item:
PolygonCollider(..., collideWith = Category:Tangible | Category:Grabbable)
To collide with any tangible collider except for shields:
PolygonCollider(..., collideWith = Category:Tangible ^ Category:Shield)
AfterCollide
await this.AfterCollide<Id?> -> entity
Waits until the end of any collision involving a collider belonging to this
entity.
- If no
Id
is provided, waits for the end of a collision involving any collider that belongs tothis
entity, except for colliders that were created withisolate=true
(see PolygonCollider parameters). - If an
Id
is provided, waits for the end of a collision involving the collider that matches thatId
.
A collision ends once the two colliders involved are no longer in contact.
If this
is nullish, waits forever.
ApplyImpulse
body.ApplyImpulse(impulse)
Applies an impulse to the body, changing its velocity.
The change in the velocity will equal the impulse divided by the body's mass.
impulse
must be a vector.
If any parameter is nullish, does nothing.
ApplyTurningImpulse
body.ApplyTurningImpulse(turningImpulse)
Applies a turning impulse to the body, changing its turn rate.
The change in the velocity will equal the turning impulse divided by the body's mass.
turningImpulse
must be a Number.
If any parameter is nullish, does nothing.
BeforeCollide
await this.BeforeCollide<Id?> -> entity
Waits until the start of a collision involving a collider belonging to this
entity.
- If no
Id
is provided, waits for a collision involving any collider that belongs tothis
entity, except for colliders that were created withisolate=true
(see PolygonCollider parameters). - If an
Id
is provided, waits for a collision involving the collider that matches thatId
.
A collision starts once the two colliders involved come into contact.
If this
is nullish, waits forever.
Body
this.Body([pos, velocity?=, heading?, turnRate?, immovable?, noRotation?,
gravityScale?, bullet?])
delete this.Body
Creates or replaces an entity's body. A body defines the physical position and velocity of an entity. Many things can be attached to a body, for example colliders, sprites, and sounds, to name a few.
this
(Entity): the entity to add a Body to. If the entity already has a Body, it will be replaced. Ifthis
is nullish, this function does nothing.pos
(Vector): the position of the body.heading
(Number): the angle of the body, in radians.velocity
(Vector): the velocity of the body.turnRate
(Number): the rate at which the body turns in radians per second.immovable
(Boolean): iftrue
, the body will not change its velocity after colliding with other bodies.noRotation
(Boolean): iftrue
, the body will not change its heading after collding with other bodies.gravityScale
(Number): a multiplier for the Gravity applied to the body. Defaults to1
.bullet
(Boolean): iftrue
, the body will use continuous collision detection. This more computationally expensive, but ensures that a fast-moving body (like a bullet or projectile) does not tunnel through other bodies.