- Home /
Question on Tag Calling.
using UnityEngine; using System.Collections;
public class blahblah : MonoBehaviour { public GameObject Top;
void OnTriggerEnter(Collider other) { Top.SetActiveRecursively(false); } }
This script works perfectly but I only want it to happen with the player. I figured tags would be the trick but I am unsure on how to call them. I tried one method but it didnt work? (I only want the SetActive to happen when it is the player. I havent used tags much in my scripting thus the question.
Shouldn't be too hard to add.
I did google and what not just not much luck finding something similar (C# preferably)
Peace,
Answer by uhahaha · Dec 17, 2010 at 09:08 AM
You need to create a tag first in the Editor, and assign the tag to your gameObject. It is not clear where your code is attached to, so I am not able to be more specific.
The tag could be used, for example, as in:
GameObject aGameObject = GameObject.FindGameObjectWithTag("your tag name");
aGameObject.SetActiveRecursively(false);
or
if(collidedObjectName.gameObject.tag == "tag name")
Ended up not using tags for what I wanted to do. But thanks anyway.
Your answer

Follow this Question
Related Questions
Help with collide triggers and calls, please. 1 Answer
Enabling / Disabling Collider Help 1 Answer
Raycast Tag hit not working 1 Answer
Check if there is a child of object, and if so, get tag? 2 Answers
Disable Box Collider on Tagged Object 2 Answers