Skip to content

Weapons

Sorra edited this page Jun 8, 2024 · 5 revisions

A large range of upgradable weapons is important in a game like Rogue Wave. This document outlines how to build them.

Ammunition

An easy upgrade for weapons is to enable them to fire more powerful ammunition. Let's work through creating an upgrade to provide Assault Rifle ammo that does an extra 10% damage.

  1. Right click in Assets/_Dev/Resources/Recipes/Ammo and select Create -> Rogue Wave -> Recipe -> Ammunition Damage Multiplier
  2. Give your new Scriptable Object a name, such as RW 556mm Damage + 10%
  3. Check Is Power Up so that it will be offered as a power up recipe in game and as a permanent upgrade.
  4. Set the dependency to (at least) the lowest mag size for this ammo type
  5. Check Is Stackable if you intend the player to be able to purchase more than one of these upgrades.
  6. Set the Ammo Type to Rogue Wave AmmoType_556mm
  7. Set other values as you see fit

That's it. Your recipe will now be offered alongside all other recipes in the game.

Passive Weapons

Passive Weapons are ones that are equipped but do not need to be fired. They auto-fire in specific patterns, in game terms they are fired by Synthos, the small humanoid incarnation of the Nanobots. Passive weapons are ideal for keeping hordes of enemies at bay.

In this section we will create a Passive Destruction Beam weapon. This will fire a beam in two directions every x seconds. Destroying the first enemy they come into contact with.

Create the Passive Weapon Object

This is the actual weapon object that will be attached to the player when equipped.

  1. Create a new script called PassiveDestructorBeam which extends Passive Weapon in Assets/_Dev/Runtime/Passive
  2. Open up Assets/_Dev/Scenes Dev/Weapon Dev
  3. Open the prefab Assets/_Dev/Resources/Prefabs/Player/Synthos - Nanobot Pawn.prefab
  4. Create an empty game as a child of the root object, rename it to Passive Destruction Beam
  5. Add Neo Serialized Game Object
  6. Add Audio Source and set the Output to Spatial Effects in the RogueWave_AudioMixer, turn off Play On Awake
  7. Add PassiveDestructorBeam component, configure the settings (paying special attention to the layers used, probably this needs to be "Enemy")
  8. Create a prefab of the weapon in Assets/_Dev/Prefabs/Weapons/Passive
  9. Click the Register Prefab With SaveGameManager button on the prefab

At this point you can startup the scene and you should see the following error message appearing periodically in the console:

image

We now need to add the Weapon effects. If you use the NeoFPS modular firearm system you then configure the weapon as you would any other NeoFPS weapon and the PassiveWeapon will pull the trigger periodically for you.

Alternatively, you can override the Fire method in the PassiveDestructorBeam class and implement the weapon effects there. If you override the Fire method you will want to include the following two lines:

PlayFireSFX();

For either approach any model objects you need should be immediately below the root of the weapon prefab.

You can see examples of passive weapons in Assets/_Dev/Resources/Prefabs/Weapons/Passive.

Once you have a working weapon it is time to integrate it is time to insert it into the game. Delete the weapon from the Synthos prefab (being sure to apply any changes to the prefab first). Then move on to the next section.

Create the Passive Weapon Pickup

The pickup is the object that will be created by the nanobots or found in the level during play. Once collected the Passive Weapon will be equipped.

  1. Create an Empty Object and call it "Passive Destruction Beam Pickup"
  2. Set the layer to Trigger Zones
  3. Add Audio Source and set the Output to Spatial Effects in the RogueWave_AudioMixer, turn off Play On Awake, add a pickup sound such as Audio Pickup Weapon
  4. Add Neo Serialized Game Object
  5. Add a Sphere Collider trigger of radius 0.5
  6. Add Pickup Trigger Zone
  7. Add Passive Pickup, Add the Passive Weapon Prefab and a suitable display mesh for this item (we will add the Recipe value in the next section)
  8. Add a model or billboard as a child
  9. Make it into a prefab in Assets/_Dev/Resources/Prefabs/Pickups/Weapons/Passive
  10. Click the Register Prefab With SaveGameManager button on the prefab

Create the Passive Weapon Recipe

The recipe is needed to enable the nanobots to build the weapon.

  1. in Assets/_Dev/Resources/Recipes/Weapon/Passive right click and select Create -> Rogue Wave -> Recipe -> Passive Item Pickup name it Passive Destruction Beam Pickup
  2. Setup the pickup as needed (minimal settings are below)
  3. Is Power Up
  4. Is Consumble
  5. Is not Stackable
  6. Set the Item Pickup to the passive item pickup created above
  7. in the item pickup set the recipe to this one

You should now be able to create a scene with a pickup already in it and collect the weapon. The Nanobots should now offer to build it when possible.

Clone this wiki locally