Nebula
Core

FrameInertia

Lets a physics prop inside a moving physics frame feel the frame's motion: crates slide aft when the ship accelerates, outwards when it turns.

generated from the sources
[RequireComponent(typeof(Rigidbody))]
[DisallowMultipleComponent]
public sealed class FrameInertia : NetworkBehaviour

Lets a physics prop inside a moving physics frame feel the frame's motion: crates slide aft when the ship accelerates, outwards when it turns. A physics frame (Container.OwnPhysicsFrame) is a scene in which its container stands still, so without this component nothing inside feels the carrier move at all.

On the authority, every NetworkBehaviour.NetworkTick, before the frame's scene steps, the body gets the fictitious acceleration of its frame, -(A + α × r + ω × (ω × r) + 2 ω × v), as ForceMode.Acceleration: A and ω are the frame's acceleration and angular velocity in its own axes (PhysicsFrameState.LocalAcceleration, PhysicsFrameState.LocalAngularVelocity), α the rate of change of ω, r and v the body's frame-local position and velocity. Each tick's value is multiplied by Scale, clamped to MaxAcceleration, then smoothed over SmoothingTicks; below MinAcceleration nothing is applied, so a crate in a cruising ship can sleep. The frame's state is sampled once per tick after the carriers moved, so the force follows the carrier one tick late.

Outside a physics frame, on a ghost, on a client and while the body is kinematic it does nothing. The frame's own gravity is not rotated: "down" stays the container's floor. Add it next to a NetworkRigidbody. See docs/frame-bodies.md D4.

Fields

Scale

public float Scale = 0f;

How much of the frame's motion the body feels: 0 none (the default), 1 all of it. Games usually set it per ship, like an inertial damper.

MaxAcceleration

public float MaxAcceleration = 20f;

The largest fictitious acceleration applied in one tick, in m/s² after Scale. Keeps a snap of the carrier (a teleport, a landing) from launching the cargo.

SmoothingTicks

public int SmoothingTicks = 6;

Ticks the acceleration is smoothed over (an exponential moving average). 1 applies each tick's value as it is.

MinAcceleration

public float MinAcceleration = 0.05f;

Below this acceleration, in m/s², nothing is applied, so a body at rest in a cruising ship can sleep.

Properties

Applied

public Vector3 Applied { get; }

The acceleration applied on the last tick, in frame-local m/s² (zero when nothing was applied).

Methods

NetworkTick

public override void NetworkTick(uint tick, float deltaTime);

OnLostAuthority

public override void OnLostAuthority();

OnContainerChanged

public override void OnContainerChanged(Container previous, Container current);

On this page