Форум

Hi, I need my agent A to move to the agent B it is connected to right when agent B connects to agent A. I.e. how can agent A move to agent B without using the moveTo(agentB.getX(), agentB.getY()) - method? I need it to move to agent B using something like moveTo(getconnectAgent.getX(),getconnectedagent.getY()); And how can I do that if agent A is connected to several other agents, moving to one after the next? thanks for any help, I am fairly lost Ben
Hi Ben, You can get the number of agents connected to this one using "getConnectionsNumber()" method. So to make the agent to move towards some connected agent, please use the code like below: int k=getConnectionsNumber(); if( k!=0 ) moveTo( getConnectedAgent(k-1).getX(), getConnectedAgent(k-1).getY() );

Ваше сообщение