Quantcast
Channel: Questions in topic: "gameobject.tag"
Browsing all 95 articles
Browse latest View live

Detect a gameObject's tag via OnCollisionEnter()

Hi, I am trying to detect the tag of a gameObject when it collides with another object. Here is my script so far: function OnCollisionEnter (collision:Collision) { if (collision.gameObject.tag ==...

View Article



[C#] Raycasts and Object Tags

I have this code that cast three rays in font of an ai to check if there if something there. then if something is there. Physics.Raycast(transform.position, left, out lhit, StayD);...

View Article

How can I get a reference to a gameobject in my C# script?

I currently have the following: public List myWalls; And in the unity property inspactor script definition area I have: My Walls Element 0: Wall1 Element 1: Wall2 Element 2: Wall3 Now I would like to...

View Article

How to rotate game object on fixed position

Hi can anybody please tell me that how to make game object rotate on fixed position! Please tell me the full procedure with steps as i'm beginner to unity.

View Article

If/Else statements effecting only specific tags

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...

View Article


BCE0019 transform not a member of Object error only in Android build

had some code working in a pc build. I switched to android build and got error. Using this code above function Update()(JS): var Block1; Block1 = GameObject.FindWithTag("Block1").transform; var...

View Article

C# How to assign tag to GameObject at runtime?

I'm trying to create and assign a tag to a GameObject so I an access it later on, but discovering that I cannot at run time assign tags to GameObjects created. For example, if I have a loop that...

View Article

Getting object tag via raycast

So i have an object tagged as "Mover", and i want other game objects to know if they are over a mover or not, i've tried a few things but i'm a bit lost. Basically the object recognizes it's over...

View Article


Array elements change Gameobject.tag

Hi I have an array of materials which I can assign in the inspector. I was wondering is there a way to have each element of the built in array change the tag of the gameobject its attached to. This...

View Article


Nothing Happens at OnTriggerEnter ?

I've got a problem about OnTriggerEnter; #pragma strict static var health : int = 100; var bullet : GameObject; var explosion : GameObject; function Start () { bullet =...

View Article

CompareTag - NullReferenceException

Collider2D Obj = Physics2D.OverlapCircle(transform.position, 0.05F); if(Obj.CompareTag("SomeTag")) { isActive = true; } NullReferenceException: Object reference not set to an instance of an object....

View Article

Null reference error can u help me to fix it ....!

hello all i am bit new to scripting in unity. im having a small issue, i want to specific effect when i hit a specific gameobject with a tag. from my code i want to shift from 1st player to second when...

View Article

Help with string to gameObject.name

I try this: void OnCollisionEnter(Collision col) void OnCollisionEnter(Collision col) { situationjump = (""+gameObject.name ""+col.gameObject.name); } But I get an error Error 3 Only assignment, call,...

View Article


Need help finding the closet player to an enemy

Hi, my game can have upto 4 players in it, and I am trying to work out how to determine which player is closest to an enemy, but I cannot seem to make the following script work. I was trying to search...

View Article

"GameObject.FindWithTag" Working with one scene but not another

Hi guys, I feel something strange is happening in one of my projects, I have this code bellow that works on one scene but not another, the one it doesn't work in is my main scene (and yes I have both...

View Article


Activate/deactivate all GameObjects with same tag c#

I'm trying to create a script which would automatically activate and reactivate all GameObjects with the tag 'Flare' on them. 'flareOnTime' is for how long it is active and 'flareOffTime' is for how...

View Article

How could I use a GameObject array to check the associated tags and toggle...

At the moment I'm trying to use an array to check each element's tag and change that object's Box Collider 2D state for each one I want. At the moment the size of the array is 7 where each element has...

View Article


Collision Detection - Strange issues! Working when it shouldnt, not working...

Good Morning Guys and Girls. Having some really weird things happening with a simple 2D box collider set to trigger. I have an NPC (Set up with box collider and 2D rigidbody) walking into a box...

View Article

Problems with Physics.Raycast

I’m making a small game that mainly just involves picking up and throwing things. To do so, I’m trying to create a Raycast on the player, so that when he gets close enough to something, it’ll show that...

View Article

How to check if two objects have same tag?

Hello, I made two objects, with same tag. And I need to check if these two objects have a same tag. How can I get current object's tag? I managed to get second object's tag but not firsts.. Please...

View Article
Browsing all 95 articles
Browse latest View live




Latest Images