Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsBody.TransformWriteMode

The method used to Write the body pose to the Transform. See _transformWriteMode.
Read time 1 minuteLast updated 10 days ago

Definition

public enum PhysicsBody.TransformWriteMode

Remarks

By default, Unity writes the Transform component after it finishes calculating the physics simulation. Set this mode to
Interpolate
or
Extrapolate
instead to interpolate positions between simulation steps. _transformObject is available only in a C# script, not in the Inspector window of a public PhysicsBodyDefinition object.

Examples

// Move a GameObject by creating a dynamic body and writing its Transform.using UnityEngine;using Unity.U2D.Physics;public class MoveGameObject : MonoBehaviour{ public PhysicsWorld world; public PhysicsWorldDefinition worldDefinition = PhysicsWorldDefinition.defaultDefinition; void Awake() { // Enable physics bodies updating transforms. worldDefinition.transformWriteMode = PhysicsWorld.TransformWriteMode.Fast2D; world = PhysicsWorld.Create(worldDefinition); } void Start() { // Create a body and shape. PhysicsBody circleBody = world.CreateBody(); CircleGeometry circleGeometry = new CircleGeometry { radius = 2f }; circleBody.CreateShape(circleGeometry); // Set body to dynamic so it falls under gravity. circleBody.type = PhysicsBody.BodyType.Dynamic; // Enable this physics body updating transforms. circleBody.transformWriteMode = PhysicsBody.TransformWriteMode.Current; // Set the updated transform as the transform of this GameObject. circleBody.transformObject = transform; }}

Fields

Value

Description

CurrentThe current body pose will be written to the Transform.
ExtrapolateThe pose extrapolated from the current body pose to a future pose based upon the current linear/angular velocities will be written to the Transform. The transform pose is essentially predictive.
InterpolateThe interpolated pose from the previous body pose to the current body pose will be written to the Transform. The transform pose is essentially historic.
OffThis body pose won't be written to the Transform.