示例#1
0
    // Update is called once per frame
    void Update()
    {
        // How long do I need to get to my target?
        float rangeToTarget = Vector3.Distance(target.position, transform.position);
        float timeToTarget  = rangeToTarget / steeringMotor.maxSpeed;       // d / d / s = s

        if (timeToTarget > maxLookAhead)
        {
            timeToTarget = maxLookAhead;
        }
        // Where will the target be in that time?

        Vector3 targetVelocity = target.GetComponent <Rigidbody>().velocity;

        Vector3 destination = target.position + targetVelocity * timeToTarget;

        SteeringFlee.DelegatedSteer(steeringMotor, destination);
    }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     move = GetComponent <Move>();
     flee = GetComponent <SteeringFlee>();
 }
示例#3
0
 // Use this for initialization
 void Start()
 {
     move        = GetComponent <Move>();
     flee        = GetComponent <SteeringFlee>();
     target_move = move.target.GetComponent <Move>();
 }