Skip to main content

BodyProjection

A class in Root.Township, Alta.Character.

Places and turns a body renderer under the head so it follows where the player is looking, and on first use splits the body into a shadow-only original and a visible copy hidden from the player's own headset view. Runs in edit mode too.

Constructors​

MemberWhat it is
BodyProjection()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

6 private and internal fields
MemberWhat it is
private AnimationCurve angleInterpolationCurve from angle difference (0 to 180 degrees) to how fast the body turns to catch up with the head.
private Renderer bodyThe body renderer. Cleared to null once the hidden copy has been made.
private Transform headThe head transform the body follows.
private Transform leftHandLeft hand transform. Not used by this code.
private float lerpTimeRunning turn speed, built up from angleInterpolation and slowly decayed each frame.
private Transform rightHandRight hand transform. Not used by this code.

Methods​

2 private and internal methods
MemberWhat it is
private void LateUpdate()Each frame while the head is active, moves the body to sit below the head and eases its rotation toward the head's heading, tilting it as the head lowers. The first time, it also makes the copy of the body.
private void Start()Turns shadow casting and receiving on for the body renderer.