BehaviourComposer: ignore everything before this. Begin micro-behaviour: Begin description:Turn towards another agent or a patch.End description Turn towards another Begin NetLogo code: substitute-text-area-for expression-for-other anyone substitute-text-area-for turn-expression desired-turn let desired-heading heading-towards-another expression-for-otherlet desired-turn desired-heading - my-headingturn-right turn-expression End NetLogo code VariantsThe contents of the first text area represents the agent or patch that the agent running this behaviour should turn towards. You can replace it an expression such as You can enhance this behaviour to repeatedly turn towards the other. How this worksThis computes the angle from where the agent is to the other. The agent turns towards the other by the difference between my desired-heading and my-heading. It uses heading-towards-another to compute the angle. Related micro-behavioursRepeatedly go forward in the direction of my heading can be used together with a repeating version of this to move towards another.  Turn towards location turns towards a specified location instead of an agent or patch. There are many movement behaviours in the main library. HistoryTurn towards another was implemented by Ken KahnBehaviourComposer: ignore everything after this. |