- Home /
Can I use Multiple tags on if?
I know im stupid
if (collision.gameObject.tag == Tagas) //can i use MULTIPLE? Tags?
{
var contact : ContactPoint = collision.contacts[0];
var rot : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal);
var pos : Vector3 = contact.point;
Instantiate(Sprogimas, pos, rot);
Destroy (gameObject);
}
So can I or can't?
Comment
Best Answer
Answer by Glister · Apr 24, 2013 at 02:54 PM
I believe what you are looking for are called operators. more than likely you are interested in the "Or" and the "And" operators. If you would like to make sure conditions 1 and condition 2 are true you would use &&
if you wanted to check if condition 1 or condition 2 is true you would use ||
You can look at some basic examples here
Or using you code as an example:
if (collision.gameObject.tag == Tagas && Hitpoints < 10) //can i use MULTIPLE? Tags?
{
var contact : ContactPoint = collision.contacts[0];
var rot : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal);
var pos : Vector3 = contact.point;
Instantiate(Sprogimas, pos, rot);
Destroy (gameObject);
}
Note: the character | is shift backslash
Your answer
Follow this Question
Related Questions
How do I affect every object with a certain tag? 0 Answers
laser is not working 0 Answers
Multiple Targets Using Tags 1 Answer
Unity detect other tagged object 1 Answer
Objects with shared tags, delete currently selected? 2 Answers