Weapons, the fun devices of destruction found across many Core games! Weapons are a specific type of Core Object that includes features like ammo, reloading, and calculating where a projectile hits.
Not everything that can be used as a weapon is actually a Weapon object in Core. In Core Content, the Game Components section has a category called Weapons with a variety of different types of weapons that you can drag and drop into your game.
In the Game Components weapon templates, weapons spawning projectiles have the Weapon icon (aim) whereas melee weapons that do damage based on whether or not the weapon hits an object have the Equipment icon (backpack). The melee weapons are not using the Weapon object. They are equipment with abilities that are assigned to the player when the player equips it.
All of the available weapons are based upon the same properties. The easiest way to create a new weapon is to start from a default weapon and tweak the properties. In the first section of the properties called Weapon, you will find parameters like Shots / Second for the fire rate or the Animation Stance to define the stance of the player. The damage is set to 0 here because the Advanced weapons are using a more specific way to damage the player, including headshots. To update the damage, open the WeaponDamageShootServer in the Server Context folder.
If the “Is Hitscan” option is enabled, no projectiles are spawned and the bullets will instantly hit the other players. If it is disabled, the weapon is shooting Projectiles that can be customized in the Projectile section. The template is a Client Context folder that is spawned with each shot. We are using a Client Context because this is just the visual aspect of the projectile, the settings of the projectile are stored in the Weapon properties. You can update the properties of the Projectile to add gravity if you want bullet drop. You can even set Bounces to 3, which means that the Projectile will bounce three times before disappearing.
Hover the names of the properties with your mouse to look at the tooltip and understand what changing this parameter will do to your projectile.
Let’s say we want to create a weapon that looks like a flower, that throws fireballs that bounces on the ground like Mario (Nintendo). Here are the three steps:
Most of your game components will have the visual part in a Client Context group to optimize your game. The server does not care how your weapon looks whereas it is really important for the players. In the Geo group inside the Client Context of any weapons, you can find the different parts of the weapon.
We can place a flower from the Core Content at the same position, remove the current model, and try to equip the weapon.
To create a projectile:
Now that the template of the projectile is created, we can add it to our weapon Properties.
To update the projectile of your weapon: