So I am trying to create a boolean that judges wether or not the player is in a box collider. Although, it dosent work because the booleans have this error message: "the variable "hitbox" is assigned but never used." Can anyone tell me why?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gunpickup : MonoBehaviour {
public GameObject pickuptext;
public bool hitbox = false;
public GameObject tablegun;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.E))
{
if (hitbox == true)
{
tablegun.SetActive(false);
}
}
}
void OnTriggerEnter(Collider col)
{
pickuptext.SetActive(true);
bool hitbox = true;
}
void OnTriggerExit(Collider col)
{
pickuptext.SetActive(false);
bool hitbox = false;
}
}
↧