facexy

 

facexy makes a turtle change its direction (heading) to point towards a given coordinate (x,y). For example, ask turtles [ facexy 0 0 ] turns all turtles in a model to face the center of the model.

Things to keep in mind when using facexy:

In the model example below, there are some fish and a single patch of food. When the add food button is clicked, we change the pcolor of the patch at (3, -3) to white, which indicates a food and we ask the fish to look at this coordinate in order to indicate that they turn to the food.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the facexy primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the facexy primitive:
 
 
Similar primitives:
face

Changes a turtle's heading towards another turtle or patch.

Read more
setxy

Moves a turtle to the exact location defined by the provided x and y coordinates.

Read more
max-pxcor

Reports the largest x-coordinate of the patches in a model.

Read more
towards

Reports the angle of the caller towards an agent.

Read more
 
Learn another primitive: