Beispiel #1
0
    public SteeringOutput Separation()
    {
        Kinematic cotm = new Kinematic()
        {
            position = getNeighborhoodCenter(prepareNeighourhood())
        };

        Debug.DrawLine(character.position, cotm.position, Color.blue);


        DynamicFlee df = new DynamicFlee(character, cotm, maxAcceleration);

        return(df.getSteering());
    }
Beispiel #2
0
    public SteeringOutput getSteering()
    {
        Vector3 explicitTarget = target.position;
        Vector3 direction      = target.position - character.position;
        float   distance       = direction.magnitude;
        float   speed          = character.velocity.magnitude;
        float   prediction;

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


        df.target.position += target.velocity * prediction;

        return(df.getSteering());
    }