So i made a script that is suposed to let me change tool when 1 2 or 3 is pressed but i cant change tool and i will just start the game with my paint tool in hand but i set it ti false in Start can somebody help me with this.
Script:
using UnityEngine;
using System.Collections;
public class changeTool : MonoBehaviour
{
public GameObject paintTool;
public GameObject buildTool;
public GameObject shootTool;
// Use this for initialization
void Start ()
{
paintTool.SetActive(false);
buildTool.SetActive(false);
shootTool.SetActive(true);
switchWeapon();
}
// Update is called once per frame
void Update ()
{
switchWeapon();
}
void switchWeapon()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
shootTool.SetActive(true);
buildTool.SetActive(false);
paintTool.SetActive(false);
if (Input.GetKeyDown(KeyCode.Alpha2))
paintTool.SetActive(false);
buildTool.SetActive(true);
shootTool.SetActive(false);
if (Input.GetKeyDown(KeyCode.Alpha3))
shootTool.SetActive(false);
paintTool.SetActive(true);
buildTool.SetActive(false);
}
}