示例#1
0
    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);
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     steeringMotor = GetComponent <CharacterSteeringMotor>();
 }
示例#3
0
 // Use this for initialization
 void Start()
 {
     steeringMotor      = GetComponent <CharacterSteeringMotor>();
     lastTargetPosition = target.position;
 }
示例#4
0
 public static void DelegatedSteer(CharacterSteeringMotor motor, Vector3 targetDirection)
 {
     DelegatedSteer(motor, targetDirection, motor.alignmentInnerRadius, motor.alignmentOuterRadius);
 }
示例#5
0
 public static void DelegatedSteer(CharacterSteeringMotor motor, Vector3 destination)
 {
     motor.Steer(motor.transform.position - destination);
 }
示例#6
0
 public static void DelegatedSteer(CharacterSteeringMotor motor, Transform delegatedTarget)
 {
     motor.Steer(motor.transform.position - delegatedTarget.position);
 }
示例#7
0
 // Use this for initialization
 void Start()
 {
     motor      = GetComponent <CharacterSteeringMotor>();
     seekTarget = transform.FindChild("seekTarget");
 }