public override void OnEnter() { if (Target != null && Destination != null) { locomoteMover = Target.Value.gameObject.AddComponent <LocomoteToPointMover>(); PlayerLocoStyle.Style locomotionStyle = PlayerLocoStyle.Style.Walk; if (Style == LocomotionStyle.Run) { locomotionStyle = PlayerLocoStyle.Style.Run; } if (WaitForFinish) { locomoteMover.OnComplete += onLocomoteComplete; } locomoteMover.MoveToTarget(Destination.Value.transform, DistanceThreshold.Value, locomotionStyle, TimeoutTime, !WaitForFinish); disableOtherLocomotionControllers(); if (!WaitForFinish) { Finish(); } } else { Finish(); } }
public void Reset() { IgnoreTranslation = false; IgnoreRotation = false; IgnoreCollisions = false; IgnoreGravity = false; IgnoreJumpRequests = false; IgnoreStickInput = false; Style = PlayerLocoStyle.Style.Run; LastModifier = null; }
public void MoveToTarget(Transform target, float distanceThreshold = 0.15f, PlayerLocoStyle.Style locomotionStyle = PlayerLocoStyle.Style.Walk, float timeoutTime = 15f, bool autoDestroy = true) { targetDestination = target; actorRadius = 0f; actorHalfHeight = 0.1f; this.timeoutTime = timeoutTime; this.autoDestroy = autoDestroy; CharacterController component = GetComponent <CharacterController>(); if (component != null) { actorRadius = component.radius; actorHalfHeight = component.height / 2f; } LocomotionTracker component2 = GetComponent <LocomotionTracker>(); if (component2.SetCurrentController <RunController>()) { runController = GetComponent <RunController>(); if (!runControllerBehaviourWasSet) { oldRunBehaviour = runController.Behaviour; runController.Behaviour = new RunController.ControllerBehaviour { IgnoreCollisions = false, IgnoreGravity = false, IgnoreRotation = false, IgnoreTranslation = false, IgnoreJumpRequests = true, IgnoreStickInput = true, Style = locomotionStyle }; runControllerBehaviourWasSet = true; } runController.ResetMomentum(); dest = targetDestination.transform.position; Vector3 vector = dest - base.transform.position; if (vector == Vector3.zero) { vector = base.transform.forward; } distThresholdSq = distanceThreshold * distanceThreshold; vector.y = 0f; elapsedTime = 0f; done = false; } if (!CanReachWaypoint()) { if (this.OnComplete != null) { this.OnComplete(); } runController.Steer(Vector3.zero); runController.SnapToPosition(dest); runController.SnapToFacing(targetDestination.transform.forward); if (autoDestroy) { UnityEngine.Object.Destroy(this); } } }
public void SetStyle(PlayerLocoStyle.Style style) { Style = style; }