- Home /
Question by
GentleRaptor · Feb 04, 2016 at 12:48 PM ·
if-statementstags
UnityException: Tag: GlassCup is not defined.
Hey, i need some help with this Script. When i trigger the if keycode it tells me : UnityException: Tag: GlassCup is not defined.
public float interactDistance = 5f; public GameObject StoreItems;
void Update ()
{
if (Input.GetKeyDown(KeyCode.E))
{
Ray ray = new Ray(transform.position, transform.forward);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, interactDistance))
{
if (hit.collider.CompareTag("Door"))
{
DoorScript doorScript = hit.collider.transform.parent.GetComponent<DoorScript>();
if (doorScript == null) return;
doorScript.ChangeDoorState();
}
if (hit.collider.CompareTag("Cornflakes"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.CornflakesPickup();
Destroy(hit.collider.transform.gameObject);
if (stealshit = null) return;
}
if (hit.collider.CompareTag("GlassCup"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.GlassCupPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Teabox"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.TeaboxPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Choclate"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.ChoclatePickUp();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("BeansAndMeat"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.BeansAndMeatPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Vegetables"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.VegetablesPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Fruits"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.FruitsPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Coffee"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.CoffeePickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("GoldenBanana"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.GoldenBananaPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Meat"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.MeatPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Cheese"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.CheesePickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Lice"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.LicePickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("TV"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.TVPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Computer"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.ComputerPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Laptop"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.LaptopPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("Toys"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.ToysPickup();
Destroy(hit.collider.transform.gameObject);
}
if (hit.collider.CompareTag("MobilePhones"))
{
StealShit stealshit = StoreItems.gameObject.GetComponent<StealShit>();
stealshit.MobilePhonesPickup();
Destroy(hit.collider.transform.gameObject);
}
}
}
}
Comment
Your answer
