Colobot Wiki
Advertisement

Instruction[]

The instruction motor( , ); sets the speed for the left-hand and the right-hand motor of the bot.

Basic use[]

The speed given to the motors will remain constant during the execution of the following instructions. Thanks to this characteristic it is possible to perform a rotation during the instruction fire();. This will sweep a whole zone with only one burst. Here is an example that will sweep the zone in front of the bot: turn(45);        // turns 45 degrees left

motor(0.5, -0.5); // slow rotation to the right 
fire(2);          // fire 
motor(0,0);       // stops the rotation

With the left-hand motor turning half-speed forward and the right-hand motor turning half-speed backward, the bot will turn slowly on itself during the 2-second-burst.

For specialists[]

Syntax :

motor ( left, right );

Gives speed instructions to the right and left motors of the robot. The motors will keep this speed until a new motor instruction is performed, or until a move, turn, or goto instruction is performed.

left: float

Speed instruction for the left motor; the value must range between -1 and 1. 

right: float

Speed instruction for the right motor; the value must range between -1 and 1. 

Examples[]

Move forward with highest possible speed:

motor(1, 1);

Move backward with half speed:

motor(-0.5, -0.5);

Turn right as fast as possible: 

motor(1, -1);

Notes[]

  • motor(2, 2); will not move forward any faster than motor(1, 1); 
  • motor(-2, -2); will not move backward any faster than motor(-1, -1);
Advertisement