Exemplo n.º 1
0
        public Vector3 GetSteering(AIMovement target, Vector3 offset, out Vector3 targetPos)
        {
            var offsetPos = target.Position + target.Transform.TransformDirection(offset);

            // Calculates the distance to the specified point away from the target
            var dist     = offsetPos - transform.position;
            var distance = dist.magnitude;

            var speed = rigbod.Velocity.magnitude;

            float prediction;

            if (speed <= distance / maxPrediction)
            {
                prediction = maxPrediction;
            }
            else
            {
                prediction = distance / speed;
            }

            targetPos = offsetPos + target.Velocity * prediction;

            return(steering.Arrive(targetPos));
        }
Exemplo n.º 2
0
        void Awake()
        {
            // Converts the cosine value into radians for use in calculations
            cosineValue = Mathf.Cos(cosine * Mathf.Deg2Rad);

            rigbod   = GetComponent <AIMovement>();
            steering = GetComponent <Steering>();
        }
        void TryToRemove(Component other)
        {
            AIMovement rigbod = other.GetComponent <AIMovement>();

            if (rigbod != null)
            {
                _targets.Remove(rigbod);
            }
        }
 void Awake()
 {
     rigbod = GetComponent <AIMovement>();
 }
 static bool IsNull(AIMovement ai)
 {
     return(ai == null || ai.Equals(null));
 }
Exemplo n.º 6
0
 void Awake()
 {
     rigbod   = GetComponent <AIMovement>();
     steering = GetComponent <Steering>();
 }