public static void DelegatedSteer(CharacterSteeringMotor motor, Vector3 targetDirection, float targetRange, float outerRange) { Transform transform = motor.transform; float angle = Vector3.Angle(targetDirection, transform.forward); Vector3 cross = Vector3.Cross(targetDirection, transform.forward); float deltaAngle = angle * cross.y < 0 ? 1 : -1; // Maybe? // If we're within targetRange, we don't need to adjust. if (angle < targetRange) { return; } // If we're outside the slowdown range, we want maximum turning. // Assume we are. float targetRotation = motor.maxRotation; if (angle < outerRange) { targetRotation *= angle / outerRange; } targetRotation *= angle / deltaAngle; float adjustment = targetRotation - motor.rotation; motor.Steer(adjustment); }
// Use this for initialization void Start() { steeringMotor = GetComponent <CharacterSteeringMotor>(); }
// Use this for initialization void Start() { steeringMotor = GetComponent <CharacterSteeringMotor>(); lastTargetPosition = target.position; }
public static void DelegatedSteer(CharacterSteeringMotor motor, Vector3 targetDirection) { DelegatedSteer(motor, targetDirection, motor.alignmentInnerRadius, motor.alignmentOuterRadius); }
public static void DelegatedSteer(CharacterSteeringMotor motor, Vector3 destination) { motor.Steer(motor.transform.position - destination); }
public static void DelegatedSteer(CharacterSteeringMotor motor, Transform delegatedTarget) { motor.Steer(motor.transform.position - delegatedTarget.position); }
// Use this for initialization void Start() { motor = GetComponent <CharacterSteeringMotor>(); seekTarget = transform.FindChild("seekTarget"); }