The gun system is a raycasting gun. The gun has a muzzle flash and impact event. Players can shoot each other and NPCs.
Players can hold up to eight guns in inventory at once.
The public variables on the gun include settings for bullet type, fire rate, range and damage. (Upcoming features will include configurable reload speeds, magazines, etc.)
Each gun also contains the Animation Override that plays idle, walk, run, damage and death sequences on the player.
This video tutorial shows how to configure and publish your own Guns and Gun Givers as inventory items that players can in place in their own customised multi-player maps in Sinespace;
The gun consists of three versions of the gun barrel (the visible gun). The other unique assets for each gun are;
In the Elements folder of the Shooter project there are three gun barrels;
The Barrel is the version players see in their own hands in third person view. The Barrel Mouseview is the version they see in mouseview, which they get to by zooming in on their mouse wheel.
The Barrel Remote is the version other players see. It has less scripts than the player’s own two versions and not use unnecessary resources during gameplay.
There are six public variables;
Bullet type will be referenced in the ammo crates and the gun bar on the Player HUD.
We recommend keeping fire rate down to a max of 8 bullets per second. (Networked pooling of bullets is in development to support higher fire rates).
The range defines how far away a target can be and still take damage.
hitDamageNPC and hitDamagePlayer set the damage done by the gun. Guns can be configured to inflict different levels of damage on player or NPC.
You can set showHits to 0 if you do not want other players to see each other’s shots. (Which is pretty sneaky, frankly.)
In the resources you can see we have the pool bullet. This is a particle effect for impact.
The other resource on the barrel is the third person animator. This is the animation override for idle, walk, run, take damage and die while carrying the gun.
Notice on the movement blend tree we blend though three sets of the idle. This ensures the player moves to idle pose even if there is marginal movement on the character and prevents it from appearing to be walking on the spot.
The damage and death animations can be used to trigger events other than character animations. For instance you can combine the FollowAvatar component with a Cinemachine camera to move to a third person, bird eye view during the death sequence, so players witness themselves dying. Horribly.
Any events you animate as part of a death sequence should match the time you set in the deathSequenceDuration public variable on the Combat Meter in the Safe Zone Lobby. Remember you also want this timed with any animated event on the Death canvas in the Killed screenspace canvas.
The Fire event triggers when the player fires the gun. It can trigger your muzzleflash and any other events, like a recoil animation on the gun (see tutorial video).
The cylinder referenced in the barrel object reference is used to position the gun in the player’s hands. It should be disabled but not deleted when you upload the gun.
The grip inside the barrel contains the disabled cylinder referenced above. You can enable this and use it to line up your gun so it fits into the player’s hands. Don’t forget to disable it. Don’t delete it!
You need to apply your gun model to all three copies of the barrel. In our experience the mouselook version benefits from being enlarged compared to the others.
The barrel has all the same settings, scripts and components as the main gun.
The Barrel mouselook has a canvas where you can insert a unique crosshair for the gun.
This is an object in the scene that gives a specific gun type to the player. The template art Gun Giver is configured as a spawnable item which players can place in the map from inventory when laying out a customised map.
The Gun Giver can be configured in numerous other ways, for instance to spawn and destroy itself as a child of an NPC, making it possible to grab the gun of a dead NPC.
Or it could be configured to give a gun as a reward for completing a side quest (see the side quest video and documentation here and here.)
The public variables on the Gun Giver include settings for gun type, bullet type and the number of bullets in the gun when first collected by the player.
There are 5 public variables on the script.
gunType is referenced here, in the gun bar and gun changer. Ensure you give each gun a unique name.
bulletType we give the same naming convention as on the barrels.
bullets is the number of bullets in the gun when you pick it up.
bulletInterval is a cooldown rate; the gun giver will also give ammo for the gun.
Order is where in the gun bar this gun will appear.
There are six resources on the Gun Giver; the three gun barrels, the 3rd person animator and the gun icon that appears in the gun bar.
Drag your versions in from the project. Do not alter the naming conventions.
The trigger activator on the base of the Gun Giver triggers the event giving the gun when the player walks within the collider attached to the object.
Note this activator is set to owner only, so I don’t give the gun to everyone in the game at once!