From Custom Mario Kart
Jump to: navigation, search

This page is a part of the Custom Track Tutorial. Back to the main tutorial page.


Cannons are triggers that make your vehicle fly any distance in any direction, to any location of the track. They are present in every Mario Kart game except for the SNES and GBA editions. In Mario Kart Wii they appear in DK Summit, Maple Treeway, Rainbow Road, N64 DK's Jungle Parkway and GCN DK Mountain. They also appear in a variety of custom tracks; although Cannon City is a track dedicated specially for cannons, the one with the biggest number of them is Jungle Island.


Cannon of N64 DK's Jungle Parkway. You can see the cannon trigger (magenta wall) and the landing zone (magenta cuboid). The picture is exported by »wkmpt DRAW --draw kcl,obj,cnpt«.

Cannons are composed of three different parts:

  • the KCL trigger location
  • the KMP destination point
  • the optional object used to represent the cannon as seen in-game.

The three must be linked properly for the cannon to work.

KCL trigger location

Now, you'll need to set up a KCL collision flag to refer to each destination point. This means that once this location is touched in the KCL, it will activate your cannon. For each cannon your track has, you need one KCL polygon that is the trigger. This is probably the most exhausting part of creating a cannon, since you need to place your triggers in the KCL model, and a new KCL has to be generated for every change on the trigger areas. More about these KCL locations is explained in the Solidity tutorial. Once this KCL area is touched, the cannon activates and you are taken to the destination point. The KCL flag used in those polygons is 0x11 (cannon trigger). It is recommended that the cannon triggers are squares that cover the entire end of the road, but any shape can be used. And design the cannon triggers as a wall, so that a jump can't miss the trigger.

Multiple Cannons

For tracks with multiple cannons, you have to set KCL flag variants. Each cannon point in the KMP has a set ID, starting with 000 for the first point, 001 for the second, etc. The KCL polygon variant must be matched with this KMP ID. There's no need to worry about this if your track has only one cannon. Since KCL variants are a 3-bit integer, only a maximum of 8 cannons is possible in any track (variants 0 to 7). See the KCL Flag page for more information.

Object (optional)

In some courses, a Launch Star (Rainbow Road) or a DK Barrel (other courses) is used to represent a cannon. These objects are not needed for the cannon to actually work, and are there just for the sights. Place them in the location of the cannon trigger. It doesn't need to be very precise, but you can experiment with the object's location. If your base track doesn't have a cannon object, you can learn how to port one in the Porting Objects section of this tutorial.

Setting up the location of the KMP destination point

This is simple; just place the point in the location where you want the cannon to drop you off at.

(Comically?) determining the angle of the Rainbow Road cannon with a protractor on the screen (well, it's faster than downloading a program just for that)

Sometimes, it is also needed to set up rotation values for each KMP cannon point. If the cannon is following the track's map either north or south (in the X axis) there is no need for any cannon point rotation. If there is any angle other than 0º or 180º made between the cannon trigger and the destination point, this angle must be set in the Y angle value. You can use KMP Modifier, or KMP Cloud to edit the Y-angle. You can use a protractor to measure the angle, try to make an educated guess or calculate the angle based on the position of the cannon triggers and destination points.

Calculate the Y Rotation

You can calculate the Y rotation by using the mathematical atan function. If POS is the cannon position and DEST the cannon destination, do the following calculations. You can get POS and DEST with any KMP tool (perhaps moving temporary a point to the cannon trigger position).

// first: get the distance for the X and Z axis:
dx = DEST.x - POS.x
dz = DEST.z - POS.z

// If function atan2() is available:
y_rotation = atan2(dx,dz)

// Alternatively you can use the base atan() function,
// but you must determine the sign by yourself:
if ( dz == 0 )
   y_rotation =  90 (or 'π/2' if calculating in rad)
   y_rotation = atan(dx/dz)

// If the result is in radiant, 
// multiply it by (180.0/π) to get degree.
y_rotation_degree = y_rotation_rad * 180.0 / π

In Wiimms SZS Tools you can simply replace the y-rotation by the function call: yDir(POS,DEST). Or you can use the command line:

wszst calc "yDir(v(POS_x,POS_z),v(DEST_x,DEST_z))"

Replace the 4 POS_* and DEST_* values by the coordinates of your model. The height (y-coordinate) is not needed.

X and Z Rotation

Setting up X and Z angles is usually not needed, since cannons are usually straight lines leading you upwards and a certain distance from the trigger. The X or Z rotation can be used to turn the vehicles in the landing zone. This needs a complex calculation. GBA Lakeside Park (igorseabra4) is the only known track using this effect.

Extra Info

  • The first cannon (whether there is one or more) should use 000 as a KMP point ID and KCL flag variant.
  • If you are using multiple cannons, each cannon ID must use a number starting at 000 and progressing as 001, 002, 003 etc on each additional cannon. The maximum is 007.
  • The settings in the "?" section of the KMP cannon point set the type of the cannon.
    • 0xFFFF - fast, straight line (most normal cannons; used in Maple Treeway and Rainbow Road)
    • 0x0001 - curved (used in DK Summit and GCN DK Mountain)
    • 0x0002 - similar to above (used in N64 DK's Jungle Parkway)
    • 0x0003 - slow (not used by an original track; goes about 1/10 or 1/15 of the normal speed)
  • The sound of the cannon is sometimes slot-specific (N64DKJP), sometimes generated by the cannon object (Maple Treeway) and sometimes both (Rainbow Road). It might also be generated by a normal KCL-based sound trigger.