Skip to content
EvilEngine.Api.Physics

BodySpec record

public sealed record BodySpec

What IPhysicsWorld.Add makes a body from: its collision, and everything else as overrides with defaults. Set what you need with with or an initialiser and leave the rest.

var crate = new BodySpec(collision)
{
    Position = new MapVector(0, 1, 0),
    Velocity = new MapVector(0, 0, -4),
    Mass = 30
};
Assembly
EvilEngine.Api
Commit
4ff877b1

Members

BodySpec constructor

public BodySpec(CollisionContent Collision)

Makes a spec for a dynamic body over collision at the origin, at rest, with its mass and surface the collision’s own.

DefaultGroup field

public const string DefaultGroup = "default"

"default", the group a body is in unless Group says otherwise.

Collision property

public CollisionContent Collision { get; init; }

The converted collision content the body’s shapes come from, its hulls, primitives and any triangle mesh. A model’s is <model>/collision, made from Source’s .phy for Garry’s Mod. It also carries the collision’s own mass and surface when it has them.

Motion property

public BodyMotion Motion { get; init; }

Dynamic unless set. A collision holding a triangle mesh can only be static or kinematic.

Position property

public MapVector Position { get; init; }

Where the body’s origin starts, in meters on Godot’s axes.

Orientation property

public Orientation Orientation { get; init; }

How the body starts turned. Identity unless set.

Mass property

public double? Mass { get; init; }

The body’s mass in kilograms, when you want to set it. Left null, it’s the collision’s own mass, as Source’s .phy gives a prop’s: 30 kg for the oil drum and the crate, 10 for the melon. A collision with no mass of its own gets its volume times its surface’s density, or 1,000 kg/m³ when the surface has none. One with no volume, only a triangle mesh, gets 1 kg.

Surface property

public ContentId? Surface { get; init; }

The id of a surface record to use instead of the collision’s own. Its friction and bounce go on the body, and its density is what Mass falls back on.

Velocity property

public MapVector Velocity { get; init; }

The starting linear velocity in m/s. Only a dynamic body takes it.

Spin property

public MapVector Spin { get; init; }

The starting angular velocity in radians a second about each axis. Only a dynamic body takes it.

Group property

public string Group { get; init; }

The collision group the body is in, DefaultGroup unless set. Nothing reads it yet: every body collides with the world, the map’s physics clip and every other body, and never with player or NPC clip.

Damping property

public double? Damping { get; init; }

How much of a dynamic body’s speed it sheds each second through the air, or null for the physics world’s own.

SpinDamping property

public double? SpinDamping { get; init; }

How much of a dynamic body’s spin it sheds each second, or null for the physics world’s own. A ragdoll’s parts take their solid’s rotdamping from Source’s .phy.

Inertia property

public double? Inertia { get; init; }

A scale on the body’s inertia, as a ragdoll solid’s inertia in Source’s .phy gives it, or null for 1. The body carries it, but the physics world doesn’t apply it yet.