// 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); }
// Start is called before the first frame update void Start() { move = GetComponent <Move>(); flee = GetComponent <SteeringFlee>(); }
// Use this for initialization void Start() { move = GetComponent <Move>(); flee = GetComponent <SteeringFlee>(); target_move = move.target.GetComponent <Move>(); }