Ejemplo n.º 1
0
    static int SortByDistance(SteeringAgent a1, SteeringAgent a2)
    {
        float distanceToPointA1 = Vector3.Distance(m_Hitpoint, a1.GetPosition());
        float distanceToPointA2 = Vector3.Distance(m_Hitpoint, a2.GetPosition());

        return(distanceToPointA1.CompareTo(distanceToPointA2) * -1);
        //return distanceToPointA1.CompareTo(distanceToPointA2);
    }
Ejemplo n.º 2
0
    public override SteeringOutput CalculateSteering(SteeringAgent agent)
    {
        SteeringOutput steering = new SteeringOutput();

        steering.LinearVelocity = m_Target - agent.GetPosition();
        steering.LinearVelocity.Normalize();
        steering.LinearVelocity *= agent.GetMaxLinearSpeed();
        steering.IsValid         = true;

        return(steering);
    }
Ejemplo n.º 3
0
    public override SteeringOutput CalculateSteering(SteeringAgent agent)
    {
        Vector3 offset = agent.GetVelocity();

        offset.Normalize();
        offset *= m_OffsetDistance;

        m_WanderAngle += Random.Range(-0.5f, 0.5f) * m_MaxAngleChange;
        Vector3 circleOffset = new Vector3(Mathf.Cos(m_WanderAngle) * m_Radius, 0, Mathf.Sin(m_WanderAngle) * m_Radius);

        m_Target = agent.GetPosition() + offset + circleOffset;

        return(base.CalculateSteering(agent));
    }