Skip to content
EvilEngine.Api.Physics

IPhysicsBody interface

public interface IPhysicsBody

One body in an IPhysicsWorld, as Add returns it. Every vector is a MapVector in meters on Godot’s axes, read from the world as it stands after the last step. Setting a number or vector, or pushing with one, that isn’t finite or is past a float’s range throws ArgumentOutOfRangeException, so Jolt never takes one, and so does an orientation of all zeros.

Assembly
EvilEngine.Api
Commit
4ff877b1

Members

Motion property

BodyMotion Motion { get; }

Whether it’s static, kinematic or dynamic, fixed when it was added.

Mass property

double Mass { get; }

Its mass in kilograms, worked out once when it was added, as BodySpec.Mass says. Only a dynamic body uses it.

Volume property

double Volume { get; }

The volume of its collision in m³: each hull by its faces, each primitive by its formula. A triangle mesh has none, so a body made only of one is 0.

Position property

MapVector Position { get; set; }

Where the body’s origin is, the origin its collision was made around, not its centre of mass. Setting it moves the body there at once, with no sweep in between.

Orientation property

Orientation Orientation { get; set; }

Its rotation as an Orientation. Setting it turns the body at once. It’s normalised on the way in.

Velocity property

MapVector Velocity { get; set; }

Its linear velocity in m/s. Setting it replaces the velocity outright.

Spin property

MapVector Spin { get; set; }

Its angular velocity in radians a second about each axis.

Centre property

MapVector Centre { get; }

Where its centre of mass is in the world, which moves with the body. The physics gun steers a held prop by it.

Frozen property

bool Frozen { get; set; }

Whether the body is held where it is, still and untouched by gravity or pushes until it’s thawed. Setting it on a dynamic body stops it dead and freezes it, and clearing it wakes it again; a static or kinematic body, or one that’s removed, ignores it and reads false.

Asleep property

bool Asleep { get; }

Whether the world has put it to sleep. A dynamic body that’s come to rest sleeps until something touches it or you change it.

GravityScale property

double GravityScale { get; set; }

How much of the world’s gravity pulls it, 1 by default. The physics gun holds a prop at 0 and puts it back to 1 when it lets go.

Removed property

bool Removed { get; }

Whether the body has left its world. A weapon that keeps a body between ticks checks it before touching the body again.

Bounds property

(MapVector, MapVector) Bounds { get; }

The box its collision covers in the world at its current position and orientation, as its lowest and highest corners.

Wake method

void Wake()

Wakes a sleeping body so the next step moves it. Setting its velocity alone may not.

Push method

void Push(MapVector impulse, MapVector at)

Applies an impulse in N·s at a point in the world, at, all at once. Pushing at the body’s Centre of mass moves it without turning it, and anywhere else, its Position included when the two differ, turns it as well.

Force method

void Force(MapVector force, MapVector at)

Applies a force in newtons at a point in the world for the next step only. Call it every tick for a force that lasts. Floating uses it for buoyancy.