Mission: Battle
The Battle mission is a multi-player skill based challenge.  CoDrones will be pitted against each other in an arena in either team or free-for-all laser-tag style battles.

Scene_07 [1]

The standard battle code is show below:

The bottom right IR sensor will send the Shooting command:

And the bottom left IR sensor will trigger the kill-switch:


Controller Inputs:


  • The bottom left IR Sensor (IR 11) is labeled bt1 in the example code and controls the kill-switch function.  Cover this sensor to instantly stop all motors on the CoDrone.  There is no penalty for using the Stop command.
  • The bottom center IR Sensor (IR 14) is labeled bt4 in the example code and controls the landing function.  Cover this sensor to initiate the Landing maneuver.  The CoDrone will descend slowly to the ground until it detects an impact, at which point all motors will turn off.  There is no penalty for using the Landing command
  • The bottom right IR Sensor (IR 18) is labeled bt 18 in the example code and controls the shooting function.  Covering this sensor will send a shooting command to the CoDrone.  The CoDrone will send an IR pulse in a narrow cone forward.  There is a movement penalty for shooting, and the CoDrone will “recoil” a little with each shot.  There is also a small, forced delay between shots (300 ms).


How to play:

1. Choose Your Team


Two drones of the same team cannot take damage from each other.  A drone on the FREE_PLAY team can take damage from any team.  Your CoDrone’s LEDs will turn the color of your selected team.

2. Arrange the CoDrones

After teams are selected and the drones are paired, each CoDrone should be arranged in a circle facing away from each other.


3. Starting the Battle

A countdown should be started from 5.  CoDrones are not allowed to fly until the countdown ends. When the countdown reaches 0, all players are free to fly their CoDrones and battle.

4. During the Battle 

Once the battle has started, each player is free to fly his or her CoDrone as they wish.  Each time a CoDrone is hit, it will flash it’s LEDs and the controller will emit a beep.  A CoDrone can be hit 8 times before it is out of Hit Points.

5. Ending the Battle

A CoDrone that has no more hit points left will turn it’s LEDs off and land.  The player’s controller will also emit a series of beeps.  The last CoDrone standing wins!


  • Each CoDrone begins with 8 Hit Points
  • Being hit costs one Hit Point
  • A CoDrone that flips over on the ground is allowed to turtle turn and resume the battle
  • A CoDrone that gets grounded and is unable to fly is considered out of the match
  • A landed CoDrone is still considered live and can still be targeted, even if it is on the ground.



Here are a few ways you can customize your battle code:

Custom “Crash” animation

You have the option of creating your own “crash” maneuver that your CoDrone performs when it is out of hit points.  To do this, you will use the functions CoDrone.CrashCustom(true)  and CoDrone.CrashedCheck() .

Setting CoDrone.CrashedCustom to true will enable CoDrone.CrashedCheck() .  We put this in setup

Now, whenever your CoDrone is out of hit points, the function CoDrone.CrashedCheck()  will return “true”.  Otherwise, it will return false.  We can use it in an if-statement to initiate our crash animation.


Change Max Hit Points

Use CoDrone.BattleHitPoints(hit points)  to set the maximum hit points for your CoDrone.

  • Default is 8
  • You can enter a range from 1-8


This is the shooting trigger.  In the default example code, the controller does not make a sound when the CoDrone shoots.  To add a sound to each shot, use the following function:

Where the first number (4000) determines the pitch of the buzz (higher number, higher pitch), and the second number (10) determines the length of the buzz (higher number, shorter buzz).


It is also encouraged to include a taunt maneuver into your code.  This is a small “drone dance” that you can initialize after a successful match.  Replace the Landing function on the bottom center IR sensor (14) with your taunt code and trigger it whenever you defeat your opponents!

This will make the CoDrone turn from right to left to right to left quickly.


Customized Example

This code will set the CoDrone to Green team.  It also starts with 4 hit points, includes a taunt, makes a buzz noise when you shoot, and has a custom crash animation.