Tapable Icons for Weapon select

Added Weapon Select mechanism:

Press 1, 2, 3 to select Rope, Shotgun and Rifle Weapon. Or simply click on the weapon icon.

On mobile just tap the weapon icons at the bottom.

Here is what it looks like

 

p12

So basically the weapon icons are UI buttons.

And on their click event, we have called the EquipWeapon method via a controller script:

Following script is attached to each button, SelectWeapon selects the weapon then the proceeding code is added to focus out the UI, so the keyboard input does not affect the UI buttons.

 

public class WeaponIconController : MonoBehaviour

{

    public void SelectWeapon(string weaponName)

    {

        LevelManager.Instance.WeaponController.EquipWeapon(weaponName);

        GameObject myEventSystem = GameObject.Find(“EventSystem”);

        myEventSystem.GetComponent<UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null);

    }

}

Thanks for reading.

if you want to check out some of our projects please subscribe to our YouTube channel:

You can check up our work in progress games here:

If you are looking for solutions to game development issues see our blogs here:

If you like our projects please sign up for our newsletter at the bottom of this Page.

Leave a Reply