How to change this.gameObject.tag?

Hi all! I have a game object whit trigger assigned. And default tag “player”. I’need this GO change its tag to something like “hummer” then onTriggerEnter occurs.

function OnTriggerEnter (other : Collider) { if (other.gameObject.tag=="wall"){ gameObject.tag="hummer"; }

the problem is that instead of changeing own tag it changes the tag of the collided object. For ex If It touch “wall” it should change own tag from “player” to “hummer”. Insted it changes the “wall” tag to “hummer”. Why?

Well, dunno if that would fix the pb but you are missing a }

2 Answers

2

function OnTriggerEnter (other : Collider)
{
if (other.gameObject.tag==“wall”)
{
other.gameObject.tag = “hummer”;
print(other.gameObject.tag);
}
//you will be check out in console

Check what he says, he wants the player to change his tag not the wall. You are changing the wall.

Thanx a lot its working