Wiki 9Minecraft Wiki 9Minecraft
Cc Optical Wiki › Guides › Automate Cannon Aiming and Firing with Sensor Data

Automate Cannon Aiming and Firing with Sensor Data

Connecting Cannon and Sensor

Place a Create Big Cannons mount next to your computer setup alongside your optical sensor or radar. Wrap both peripherals in your Lua script using peripheral.wrap(). The cannon mount becomes a scriptable peripheral that accepts pitch and yaw angle commands.

Reading Target Coordinates

Run a sensor scan and extract target position data from the detection results. Calculate the angle offsets needed to aim your cannon at the detected target. Most targeting scripts convert 3D coordinates into pitch (vertical) and yaw (horizontal) angles relative to your cannon's position.

Sending Angles to the Cannon

Use the cannon peripheral's methods to set pitch and yaw values directly. Check the cannon's rotation limits and weight capacity before firing—use isLoaded() to verify the cannon is ready. Some setups require checking maximum rotation angles to prevent mechanical strain.

Automating the Fire Sequence

Once angles are set, call the fire command through the peripheral. Add delays between shots to allow reloading. Wrap the entire process in a loop that continuously scans for targets, calculates angles, aims, and fires automatically. This creates a fully autonomous defense turret.