# BodySpec record

> 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.

Namespace `EvilEngine.Api.Physics`, assembly `EvilEngine.Api`. Engine commit 4ff877b1.

```csharp
public sealed record BodySpec
```

What [IPhysicsWorld.Add](/docs/api/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.

```csharp
var crate = new BodySpec(collision)
{
    Position = new MapVector(0, 1, 0),
    Velocity = new MapVector(0, 0, -4),
    Mass = 30
};
```

## Members

### BodySpec (constructor)

```csharp
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)

```csharp
public const string DefaultGroup = "default"
```

`"default"`, the group a body is in unless [Group](#group) says otherwise.

### Collision (property)

```csharp
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)

```csharp
public BodyMotion Motion { get; init; }
```

[Dynamic](/docs/api/bodymotion#dynamic) unless set. A collision holding a triangle mesh can only be static or kinematic.

### Position (property)

```csharp
public MapVector Position { get; init; }
```

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

### Orientation (property)

```csharp
public Orientation Orientation { get; init; }
```

How the body starts turned. [Identity](/docs/api/orientation#identity) unless set.

### Mass (property)

```csharp
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)

```csharp
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](#mass) falls back on.

### Velocity (property)

```csharp
public MapVector Velocity { get; init; }
```

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

### Spin (property)

```csharp
public MapVector Spin { get; init; }
```

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

### Group (property)

```csharp
public string Group { get; init; }
```

The collision group the body is in, [DefaultGroup](#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)

```csharp
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)

```csharp
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)

```csharp
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.
