Skip to main content

aim

Function aim 

Source
pub fn aim(component_id: i32, angle: f32) -> Result<(), MessageError>
Expand description

Aims a robot component towards a specified angle in a 2D coordinate system.

This function aims the specified robot component_id towards the given angle within a 2D coordinate system where:

  • The origin (0,0) is at the center of the map.
  • Y-axis points upwards.
  • X-axis points to the right.
  • Angle measurement:
    • 0 degrees: Towards the right (positive X-axis).
    • 90 degrees: Towards the top (positive Y-axis).
    • 180 degrees: Towards the left (negative X-axis).
    • 270 degrees: Towards the bottom (negative Y-axis).

§Arguments

  • component_id - The identifier of the robot component to aim.
  • angle - The target angle in degrees (0 to 360), where 0 degrees points towards the right.

§Returns

Returns Ok(()) if the aiming operation is successful, or an error of type MessageError if there was a problem during communication with the game server.

§Examples

let result = rbot::aim(0, 90);

// If something went wrong in the communication with the server, print it
// out to the game console.
if result.err {
    rbot::print("Failed communicating with the game server.")
}