Skip to main content

State Based Physics API

When creating captures with state-based physics enabled (see below), you can make use of this API to modify Rigidbody properties in your replays.

Use of this API requires the State-based Physics option to be enabled in the Capture tab. You can read more on this here, as well as information on the Capture Collisions option.


State-based Physics Available Functions:

public delegate Vector3 PositionModifier( Vector3 newPosition, Rigidbody body );
public delegate Quaternion RotationModifier( Quaternion newRotation, Rigidbody body );
public delegate Vector3 VelocityModifier( Vector3 newVelocity, Rigidbody body );
public delegate Vector3 AngularVelocityModifier( Vector3 newAngularVelocity, Rigidbody body );

public static PositionModifier Luna.Replay.Api.PositionFunction { get; set; }
public static RotationModifier Luna.Replay.Api.RotationFunction { get; set; }
public static VelocityModifier Luna.Replay.Api.VelocityFunction { get; set; }
public static AngularVelocityModifier Luna.Replay.Api.AngularVelocityFunction { get; set; }
  • PositionModifier: Allows you to manipulate the Rigidbody.position of an object (body).
  • RotationModifier: Allows you to manipulate the Rigidbody.rotation of an object (body).
  • VelocityModifier: Allows you to manipulate the Rigidbody.velocity of an object (body).
  • AngularVelocityModifier: Allows you to manipulate the Rigidbody.angularVelocity of an object (body).


Below you can see an implementation of the PositionModifier function to move all positions by 2 on the x axis.

    protected void Awake() {
StateBasedPhysics.PositionFunction = ( position, body ) => {
position.x += 2;
return position;