Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Booleans are "asssigned but never used"???

$
0
0
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; } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>