The following is a description of a cannon, created by Wizardry and Steamworks and offered freely on marketplace, that is designed to calculate and display various firing parameters. It is a simplistic variation on artillery since the cannon does not fire automatically but instead allows the user to control the firing parameters. Possible applications can include role-play simulators or the like and possibly an implementation of the various tank-like games (Worms, etc...).

Asset | Description |
---|---|

Cannon Firing Sound |

- Unpack the jute and extract the cannon, sample wall and quick help document.
- Rez the cannon.
- Place the wall somewhere no further than away from the cannon.
- Use the arrows on the cannon gear box to rotate the cannon and elevate the barrel.
- Long-press (left-click and hold) the barrel to accumulate velocity.
- Release the left mouse button and the cannon will fire.

The sample wall contains the health script and can be molded into a different object. Or, the script can be taken out and placed in an entirely different build. When the health meter reaches zero, the script pauses for one second and then derezzes the build.

It is possible to build a small enclosure around the cannon and play a tank-like game where each player must destroy the other players' fortresses.

The following section describe the various calculations performed by the cannon. These calculations not only determine the firing velocity but computes various data for the overhead text. The cannon computes the horizontal distance (grid-distance) to the impact coordinates and also displays the nozzle elevation.

The initial velocity increments linearly by touch-and-holding the cannon barrel. When the avatar stops touching the barrel, the cannonball is fired with the accumulated velocity.

The velocity vectors for and where represents the horizontal axis and represents the elevation are given by:

When the vertical component is zero at peak altitude, we have that:

thus, extracting , the time to reach the peak altitude, we obtain:

By design we have that the capped maximum velocity () of the cannon is . We also know that the maximal distance can be obtained by making . This is because of the and functions overlap at :

Would we have chosen any angle so that , then the and would have started to decrease, one in function of the other.

Thus, substituting for and , we have:

And at peak altitude, since the gravitational acceleration is :

Deriving in time, we have that:

Since it takes the same amount of time to reach maximum altitude as it takes to fall back down, we have that:

We obtain that for a maximum elevation of and a maximum firing velocity of , the horizontal travel distance is:

which gives us the maximum firing range for the cannon.

- The maximum firing distance is given from the above calculations as .
- The maximum firing velocity is .
- The minimum firing velocity is capped at . This is to ensure that the projectile travels through the barrel (since the projectile rezzes at the centre of the barrel and is not bounded by the barrel's dimensions).
- The maximum elevation of the barrel is starting from .

secondlife/artillery/cannon.txt · Last modified: 2017/02/22 18:19 (external edit)