Exemplo n.º 1
0
        public int AddBehaviour(ISteeringBehaviour behaviour)
        {
            TryInitialize();

            Debug.Assert(!m_behaviours.Contains(behaviour));

            var index = m_behaviours.Count;

            m_behaviours.Add(behaviour);
            return(index);
        }
Exemplo n.º 2
0
 public static Vector2 Flee(Vector2 threatPosition, ISteeringBehaviour agent)
 {
     return(agent.CalculateForceForDirection((agent.position - threatPosition).normalized));
 }
Exemplo n.º 3
0
        public static Vector2 Seek(Vector2 targetPosition, float targetRadius, float epsilonRadius, ISteeringBehaviour agent)
        {
            var dPos = targetPosition - agent.position;

            var distanceToTarget = dPos.magnitude;
            var speedMultiplier  = 1.0f;

            if (targetRadius > 0.0f)
            {
                speedMultiplier = Mathf.Clamp01(Mathf.InverseLerp(0.0f, targetRadius, distanceToTarget));
            }
            if (distanceToTarget < epsilonRadius)
            {
                speedMultiplier = 0.0f;
            }

            return(agent.CalculateForceForDirection(dPos.normalized, speedMultiplier));
        }
Exemplo n.º 4
0
 public void RemoveBehaviour(ISteeringBehaviour behaviour)
 {
     m_behaviours.Remove(behaviour);
 }