IStandardRobotPeer SetAdjustGunForBodyTurn Method 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 IsAdjustGunForBodyTurn(true). 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).

Examples

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

Note: The gun compensating this way does count as "turning the gun". See SetAdjustRadarForGunTurn(Boolean) for details.

Namespace: Robocode.RobotInterfaces.Peer
Assembly: robocode (in robocode.dll) Version: 1.9.3.0
Syntax

void SetAdjustGunForBodyTurn(
	bool independent
)

Parameters

independent
Type: OnlineSystem Boolean
true if the gun must turn independent from the robot's turn; false if the gun must turn with the robot's turn.
See Also