public Vector3 Follow(Vector3 leader) { return((leader - boid.GetPosition()).normalized * boid.GetMaxVelocity()); }
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; }
public static Vector2 Seek(IBoid boid, Vector2 position) { var desiredVelocity = (position - boid.GetPosition()).normalized * boid.GetMaxVelocity(); return(desiredVelocity - boid.GetVelocity()); }