Quantcast
Channel: Questions in topic: "gameobject.tag"
Viewing all articles
Browse latest Browse all 95

If/Else statements effecting only specific tags

$
0
0
Hi, I want to create various scenarios that effect only specific gameObjects with specific tags. These scenarios all come in the form of if/else statements. For these examples, let's just include the tag "enemy" as our example. The goal is to have A) time effect the enemy, but not me. B) have the enemy's position effected, but mine is unaffected. Obviously, the only hard part is applying the gameObject's tag correctly. Thus, I will just provide a brief sample of scenario A. Here is the code: if (Input.GetKey("z")) { Time.timeScale = 0.5; } This code is clearly not complete. I am wondering how I add the `if (other.gameObject.tag=="enemy")` portion of the code so that I can isolate the effects to the enemy. I'm sure I can write the other part of the code, I just need help with this part. Sorry if this question seems really obvious and stupid, but it is causing some confusion for me. Thanking everyone in advance for taking a look at this, and/or for trying to help.

Viewing all articles
Browse latest Browse all 95

Latest Images

Trending Articles





Latest Images