Weapons Rack : Getting Started

How to deploy a weapons rack and firing a Weapon

A simple tutorial to get you started. I assume you know your way around Unity, but will explain as much as needed to ensure success but the end. So read everything twice.

Selecting a Rack

By default the Weapons Rack Asset pack comes with a number of pre-configured racks and one empty rack. These can be found in WeaponsRack/Prefabs/Racks. Along with this empty rack you will find a number of pre-configured demo racks.

In your project view select the empty weapons rack and make a duplicate of it. To do this right click the empty rack prefab and select duplicate, or by pressing CTR+d after selecting the rack.

Next rename the duplicate weapons rack to something useful. For instance 'mainWeaponsRack'.

Drag this new prefab in to your scene.

You should see a red object tag appear in your scene with the name of your prefab in it. Like this...

You can play your scene, and see... nothing!?!

This is because the empty rack is still empty.

Adding a weapon to the rack.

Programatiacly.

weaponsRack WeaponsRack.addWeapon(Weapon weapon);

Through Unity Editor

This assumes you already have a weapon prefab ready to go. If not check out the section on weapons.

In your scene view or hierarchy panel, select your weaponsRack prefab. This will display the Object Inspector. If it is not already, expand the Weapons Rack script component properties. At the bottom of the list expand the Weapons List. Set the size to 1

Next in the Project panel, navigate to your weapons prefab. Drag the weapons prefab in to the weapons rack's weapons list.

Play your scene. If your weapon is set up correctly you should see your weapon firing