I have an agent moving in a MoveTo block (in GIS space), I need to stop it from another block when a certain condition is met and then resume the movement after a timeout.
I tried this in the "On enter" action of the other block:
if(moveToBlock.size()>0){
for( Agent tr : moveToBlock.agents()){
tr.setSpeed(0);
timeOutEvent.restart();
};
}
And this in the timeOutEvent to resume the movement:
for( Agent tr : moveToBlock.agents()){
tr.setSpeed(800);
};
But the agent keeps moving. How can I achieve this?
If you have to stick to the MoveTo
block setup (might not be the best solution), you can call myMoveToBlock.remove(agent)
on the moving agent in question, then call stop()
on the agent.
Add an Enter
block that feeds into the MoveTo
block.
When it is time to restart the movement, tell the agent that previously stopped to myEnterBlock.take(agent)
It will then re-enter the MoveTo
block and restart the movement.
PS: You may want to consider switching away from process blocks for GIS movements, though...