Ejemplo n.º 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);
    }