Skip to main content

AgentRollUpInPlace

A class in Root.Township, Alta.Intelligence.

Server: running action that turns an upside down or tipped crawler back upright onto the nearest ground surface, then can switch action sets. Settings come from AgentRollUpInPlaceSettings.

Constructors​

MemberWhat it is
AgentRollUpInPlace()Creates an AgentRollUpInPlace with default values.

Fields​

6 private and internal fields
MemberWhat it is
private Transform transformThe creature's rigidbody transform, moved directly.
private Vector3 turningUpNormalNormal of the surface the creature is turning onto.
private Vector3 turningUpPositionGround point the creature ends up on.
private Quaternion turningUpRotationUpright rotation the creature turns to.
private IUnityUpdateMethod updateThe registered TurnUp update.
private static UpdateModule updateModuleShared "Turn up Update" fixed update module.

Methods​

MemberWhat it is
override void Update(bool hasTarget)Does nothing. The turning runs in TurnUp.
protected override void OnStart()Works out the turn and registers TurnUp on its fixed update module.
6 private and internal methods
MemberWhat it is
private void CalculateTurn()Finds the nearest ground point and normal around the creature and works out the upright position and rotation to turn to. Falls back to world up.
private AgentRollUpInPlace.Point GetClosestPoint(Collider collider, Vector3 point, Quaternion rotation)Gets the closest point on a ground collider. Non-convex mesh colliders are raycast instead, since ClosestPoint doesn't work on them.
private void OnFinished(IActiveAction active)Stops the turn update and switches to the ExitTo set if one is set.
private void TerminateUpdate(IActiveAction finished)Deregisters the TurnUp update. The overload taking an action is the cancel handler.
private void TerminateUpdate()Deregisters the TurnUp update. The overload taking an action is the cancel handler.
private void TurnUp()Fixed update: rotates the creature towards the upright rotation, pivoting around the ground contact, and finishes once it's there.