Apex.Steering.Components.SteerForUnitAvoidanceComponent.GetAvoidVector(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, IUnitFacade, UnityEngine.Vector3, UnityEngine.Vector3, IUnitFacade, float)

Here are the examples of the csharp api Apex.Steering.Components.SteerForUnitAvoidanceComponent.GetAvoidVector(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, IUnitFacade, UnityEngine.Vector3, UnityEngine.Vector3, IUnitFacade, float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

private Vector3 Avoid(IIterable<IUnitFacade> units, int unitsLength, Vector3 currentVelocity)
        {
            Vector3 selfPos = _unitData.position;
            Vector3 normalVelocity = currentVelocity.normalized;
            Vector3 combinedAvoidVector = Vector3.zero;

            // iterate through scanned units list
            for (int i = 0; i < unitsLength; i++)
            {
                var other = units[i];
                if (!other.isAlive)
                {
                    continue;
                }

                if ((_ignoredUnits & other.attributes) > 0)
                {
                    // other unit is found in the ignored attributes, so ignore it
                    continue;
                }

                if (_unitData.transientGroup != null && object.ReferenceEquals(other.transientGroup, _unitData.transientGroup))
                {
                    // ignore units in same transient unit group
                    continue;
                }

                if (other.determination < _unitData.determination)
                {
                    // ignore units with lower determination
                    continue;
                }

                Vector3 otherPos = other.position;
                Vector3 direction = otherPos.DirToXZ(selfPos);
                float distance = direction.magnitude;
                if (distance > _omniAwareRadius && Vector3.Dot(normalVelocity, direction / distance) > _fovReverseAngleCos)
                {
                    // the other unit is behind me and outside my 'omni aware radius', ignore it
                    continue;
                }

                float combinedRadius = _unitData.radius + other.radius + radiusMargin;
                Vector3 otherVelocity = other.velocity;
                Vector3 avoidVector = GetAvoidVector(selfPos, currentVelocity, normalVelocity, _unitData, otherPos, otherVelocity, other, combinedRadius);
                if (acreplacedulateAvoidVectors)
                {
                    // if acreplacedulating, then keep summing avoid vectors up
                    combinedAvoidVector += avoidVector;
                }
                else
                {
                    // if not acreplacedulating, then break after the first avoid vector is found
                    combinedAvoidVector = avoidVector;
                    break;
                }
            }

            return combinedAvoidVector;
        }