Robot IsAdjustGunForRobotTurn Property Robocode Robot API for .NET
Sets the gun to turn independent from the robot's turn.

Ok, so this needs some explanation: The gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, then the gun will turn with it as it is mounted on top of the robot's body. To compensate for this, you can call IsAdjustGunForRobotTurn. When this is set, the gun will turn independent from the robot's turn, i.e. the gun will compensate for the robot's body turn.

Note: This method is additive until you reach the maximum the gun can turn. The "adjust" is added to the amount you set for turning the robot, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).


Assuming both the robot and gun start Out facing up (0 degrees):
// Set gun to turn with the robot's turn
SetAdjustGunForRobotTurn(false); // This is the default
// At this point, both the robot and gun are facing right (90 degrees)
// Both are back to 0 degrees
// Set gun to turn independent from the robot's turn
// At this point, the robot is facing right (90 degrees), but the gun is still facing up.
// Both are back to 0 degrees.
-- or --

Note: The gun compensating this way does count as "turning the gun".

Namespace: Robocode
Assembly: robocode (in robocode.dll) Version:

public virtual bool IsAdjustGunForRobotTurn { get; set; }

Property Value

Type: OnlineBoolean
See Also