Exemplo n.º 1
0
    public Vector2 CalculateBehind()
    {
        Vector2 targetVel = leader.GeRightVector() * -1;

        targetVel = targetVel.normalized * leader.GetBehindLength();

        return(leader.GetPosition() + targetVel);
    }
Exemplo n.º 2
0
    private Vector3 doPursue(IBoid target)
    {
        Vector3 distance = target.GetPosition() - host.GetPosition();
        float   updates  = distance.magnitude / host.GetMaxVelocity();
        Vector3 tv       = target.GetVelocity();

        tv = this.ScaleBy(tv, updates);
        Vector3 targetFuture = target.GetPosition() + tv;

        return(doSeek(targetFuture, 10f));
    }
    // Update is called once per frame
    void Update()
    {
        steering.seek(endzone.GetPosition());
        //steering.evade(defense);

        steering.update();

        gameObject.transform.position = steering.position + steering.velocity;
    }
Exemplo n.º 4
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.º 5
0
 public Vector3 Follow(Vector3 leader)
 {
     return((leader - boid.GetPosition()).normalized * boid.GetMaxVelocity());
 }
Exemplo n.º 6
0
    public static Vector2 Seek(IBoid boid, Vector2 position)
    {
        var desiredVelocity = (position - boid.GetPosition()).normalized * boid.GetMaxVelocity();

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