Was the v1.32 update not enough to quench your thirst for new weapons? Have no fear, custom guns are here!

Using the provided trigger system, you can now create your own guns for PB2. It's a somewhat limited system, however, and is only suitable for SP maps. (The trigger system should be adaptable for MP, but would require more complexity)

For an explanation on how the math works, take a look at the bottom spoilers.

Custom Guns

Open sourced so you guys can create your own custom guns.

- The weapon model can be changed by replacing the #d/gunModel*1 decoration
- Weapon stats can be set in #setUp*1

Note: the current trigger system only allows for the gun to be used by one player.Map ID: ditzy-customgun

Map Page Link:

https://www.plazmaburst2.com/?s=9&a=&m=ditzy-customgunMap Demo Link:

https://www.plazmaburst2.com/?s=2&map=ditzy-customgunMap Source Link:

https://www.plazmaburst2.com/level_edit ... -customgun----

It uses the same trig system as the can of soda, which can be found here:

Map demo:

https://www.plazmaburst2.com/?s=2&map=ditzy-sodaMap source:

https://www.plazmaburst2.com/level_edit ... zy-soda&a=Below is an explanation of how the math for atan2 works.

Let's say you're holding a can of soda 2 feet away from you, at arm level (0°). Now let's say you lower your arm. The soda is still 2 feet away from you, but now it's 30° below your shoulders. Let's say you raise your arm. The soda is now 30° above your shoulders.

Not only do we need to figure out how far away the can of soda is from our player, but we need to know at what angle it is.

How do we find the angle? We can use the atan2 method.

For our purposes, atan2 calculates the angle between two straight lines. The first line is a horizontal line running along the x axis (The lines is at 0°). The second line is a line that's drawn between point A and point B. In this instance point B will be our arm, and point A will be our hand.

If you take a look at the atan2 trigger action, you'll notice that there's only room to input the x and y positions of 1 point. That's because the atan2 method actually calculates the angle between point A and grid position 0,0 (This is what the computer considers point B).

However, we need point B to be the location of the arm to get accurate angles. How do we do this? If we subtract the position of the arm from the position of the hand, the result will give us a position that's relative to grid position 0,0. We can put that relative value into the atan2 method to get us an angle that accurately reflects the angle of the player's hands.

Now that we have the angle that the player is holding the can of soda, we need to figure out how far away the can of soda is from the player. Doing that is simple enough. We perform the sin and cos methods on our angle. We can then multiply the sin and cos values by the distance our can of soda had when at arms level (0°).

Finally, with a little more math(mainly finishing the calculations for the player's position) we have a finished trigger system that allows you to hold a can of soda!

New math for the custom guns.

All that's really added is a trigger action that rotates the gun to the angle that was given by the atan2 function, and another trigger system to check if the gun is upside down, in which case the image will be flipped on the y axis to correct it.