my code is this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunToggle : MonoBehaviour
{
public GameObject Gun;
public GameObject Grapple;
// Update is called once per frame
void Update()
{
// Reverse the active state every time escape is pressed
if (Input.GetKeyDown(KeyCode.Z))
{
// Check whether it's active / inactive
bool isActive = Gun.activeSelf;
Gun.SetActive(!isActive);
}
// Reverse the active state every time escape is pressed
if Gun.SetActive(true);
{
Grapple.SetActive(false);
}
if Gun.SetActive(false);
{
Grapple.SetActive(true);
}
}
}
↧