- Home /
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 }
Answer by Lav-patel · Apr 06, 2012 at 09:57 AM
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.
Your answer
Follow this Question
Related Questions
Hi, getting error cs1041 in my code:identifier expected, "this" is a keyword; need solution please 3 Answers
Disabling GameObjects With A Tag That Are More Than A Set Distance From A GameObject? 2 Answers
OnTriggerEnter triggers twice when changing the parent of a gameObject inside of a collider. 1 Answer
Using parent tag on whole gameObject 1 Answer
Is there a way to get the actual joystick.Vertical and joystick.Horizontal Value?, 0 Answers