示例#1
0
    //funcion que realiza seeking de un punto si le pasas 1 y flee si le pasas
    //0
    public KinematicSteeringOutput getSteering2(Vector3 targetPosition, int seek_or_flee)
    {
        //velocidades de salida
        KinematicSteeringOutput steering = new KinematicSteeringOutput();

        if (seek_or_flee == 1)
        {
            steering.velocity = targetPosition - character.transform.position;
        }
        else
        {
            steering.velocity = character.transform.position - targetPosition;
        }

        steering.velocity.Normalize();

        steering.velocity *= maxspeed;


        character.GetNewOrietation(steering.velocity);

        steering.rotation = 0f;

        return(steering);
    }
示例#2
0
    //funcion que realiza seeking de un punto y se detiene si lo alcanza en un radio
    //dado
    public KinematicSteeringOutput getSteering()
    {
        //velocidades de salida
        KinematicSteeringOutput steering = new KinematicSteeringOutput();


        steering.velocity = target.transform.position - character.transform.position;

        if (steering.velocity.magnitude < radius)//si ya estamos en el radio
        {
            steering.rotation = 0f;
            steering.velocity = Vector3.zero;
            return(steering);
        }

        //tenemos que ajustar la velocidad para que
        //cada vez que este mas cerca vaya mas lento
        steering.velocity /= timeToTarget;

        if (steering.velocity.magnitude > maxspeed)
        {
            steering.velocity.Normalize();
            steering.velocity *= maxspeed;
        }

        character.GetNewOrietation(steering.velocity);

        steering.rotation = 0f;
        return(steering);
    }
示例#3
0
 // Update is called once per frame
 void Update()
 {
     steeringAgent.UpdateSteering(blendFlock.getSteering());
     kineticsAgent.GetNewOrietation(kineticsAgent.velocity);
 }