This method is called when your robot collides with another robot. You should override it in your robot if you want to be informed of this event.
Example:
void onHitRobot(HitRobotEvent event) { if (event.getBearing() > -90 && event.getBearing() <= 90) { back(100); } else { ahead(100); } } -- or perhaps, for a more advanced robot -- public void onHitRobot(HitRobotEvent event) { if (event.getBearing() > -90 && event.getBearing() <= 90) { setBack(100); } else { setAhead(100); } }
The angle is relative to your robot's facing. So 0 is straight ahead of you.
This event can be generated if another robot hits you, in which case {@link HitRobotEvent#isMyFault() event.isMyFault()} will return{@code false}. In this case, you will not be automatically stopped by the game -- but if you continue moving toward the robot you will hit it (and generate another event). If you are moving away, then you won't hit it.
@param event the hit-robot event set by the game
@see HitRobotEvent
@see Event