# Instance ID problem

**URL:** https://discussions.unity.com/t/instance-id-problem/475487
**Category:** Scripting
**Tags:** Scripting
**Created:** [May 5, 2012, 11:49am UTC](https://discussions.unity.com/t/instance-id-problem/475487 "2012-05-05T11:49:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_38083795](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@anon\_38083795](https://discussions.unity.com/u/anon_38083795)
#### Post date: [May 5, 2012, 11:49am UTC](https://discussions.unity.com/t/instance-id-problem/475487/1 "2012-05-05T11:49:42Z")

</div>

SOLVED

Dear Community,

I’ve got a GameObject with 2 empty child GameObjects. Im using the child GameObjects as triggers. I need to get the parent GOs InstanceID. Problem is, the same objects InstanceID is different depending on from where I read it out. So reading out the InstanceID from a script on the parent object gives me a different InstanceID the the one I get by reading it out from a script on the child object. Strangely, the returned InstanceIDs always differs by 2.

Example - Script on the parent object

> [@](#):
>
> gameObject.GetInstanceID()

returns e.g. -31200

Example - Script on the child object

> [@](#):
>
> transform.parent.GetInstanceID()

returns e.g. -31202

Do you know why it behaves like this? Did I do any mistake?  
The ugly workaround would to do a +2 to get to the same ID but I’d prefer a real solution.

Thanks for your help

Example - Script on the child Object needs

> [@](#):
>
> transform.parent.gameObject.GetInstanceID();

---

<div class="post-metadata">

### Author: ![gilley033](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@gilley033](https://discussions.unity.com/u/gilley033)
#### Post date: [January 27, 2014, 10:00pm UTC](https://discussions.unity.com/t/instance-id-problem/475487/2 "2014-01-27T22:00:00Z")

</div>

This is old, and you have solved it, but I see you never explained how you solved it.

In case anyone else is wondering, the problem is that

```auto
transform.parent

```

refers to the transform of the parent rather than the game object.

You need to use  
`transform.parent.gameObject.GetInstanceID();`  
to get the instance id of the parent game object.
