Exemplo n.º 1
0
 public Vector3 Follow(Vector3 leader)
 {
     return((leader - boid.GetPosition()).normalized * boid.GetMaxVelocity());
 }
Exemplo n.º 2
0
    public void update()
    {
        velocity = host.GetVelocity();

        position = host.GetPosition();

        steering = new Vector3(
            Mathf.Clamp(steering.x, -host.GetMaxVelocity(), host.GetMaxVelocity()),
            Mathf.Clamp(steering.y, -host.GetMaxVelocity(), host.GetMaxVelocity()),
            Mathf.Clamp(steering.z, -host.GetMaxVelocity(), host.GetMaxVelocity())
            );

        velocity += steering;

        velocity = new Vector3(
            Mathf.Clamp(velocity.x, -host.GetMaxVelocity(), host.GetMaxVelocity()),
            Mathf.Clamp(velocity.y, -host.GetMaxVelocity(), host.GetMaxVelocity()),
            Mathf.Clamp(velocity.z, -host.GetMaxVelocity(), host.GetMaxVelocity())
            );

        position += velocity;
    }
Exemplo n.º 3
0
    public static Vector2 Seek(IBoid boid, Vector2 position)
    {
        var desiredVelocity = (position - boid.GetPosition()).normalized * boid.GetMaxVelocity();

        return(desiredVelocity - boid.GetVelocity());
    }