Ok. I have to make a team which surrounds the enemy. and shoots at it when it
surrounds the enemy. I have more or less got them to surround the enemy (some
group together and shoot each other).for now I set it to fire when they get
the message about the enemy, Is there a way to make them shoot only when they
are a certain distance from the enemy?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, one thing you could do is to create your own Condition, i.e. create a
class that inherits from Condition, which should return true when it fulfills
your criteria, e.g. like this:
In you run() method of your robot, you must add this line before your main
loop (e.g. while(true)):
addCustomEvent(new FireDistanceCondition);
Next you should implement an event handler for your custom event:
publicvoidonCustomEvent(CustomEventevent){
if(event.getCondition()instanceofFireDistanceCondition){
setFire(1); // or alternatively use fire(1) instead}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, the formatting for the last part went wrong. Here it is:
...
Next you should implement an event handler for your custom event:
publicvoidonCustomEvent(CustomEventevent){
if(event.getCondition()instanceofFireDistanceCondition){
setFire(1); // or alternatively use fire(1) instead}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok. I have to make a team which surrounds the enemy. and shoots at it when it
surrounds the enemy. I have more or less got them to surround the enemy (some
group together and shoot each other).for now I set it to fire when they get
the message about the enemy, Is there a way to make them shoot only when they
are a certain distance from the enemy?
Well, one thing you could do is to create your own Condition, i.e. create a
class that inherits from Condition, which should return true when it fulfills
your criteria, e.g. like this:
In you run() method of your robot, you must add this line before your main
loop (e.g. while(true)):
Next you should implement an event handler for your custom event:
Sorry, the formatting for the last part went wrong. Here it is:
...
Next you should implement an event handler for your custom event: