x


How can I get a parent GameObject of gameObject using Javascript?

I have grouped few GameObject into one GameObject. Is it possible to get the parent GameObject if you know the child GameObject using Javascript?

Something similar to the transform.parent.

more ▼

asked Mar 01 '10 at 03:06 AM

Lipis gravatar image

Lipis
2.3k 10 22 48

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

childObject.transform.parent.gameObject

more ▼

answered Mar 01 '10 at 03:25 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

It was easier than I thought :)

Mar 01 '10 at 03:51 AM Lipis

Thanks, Eric I was searching for that for ages!

Apr 06 '10 at 03:19 PM alexnode

Similar, how i get a specific child object without using for loop?

Feb 15 at 03:51 AM sona.viswam
(comments are locked)
10|3000 characters needed characters left

Thanks hahaha finally this power is miiiiine!

more ▼

answered Nov 15 '10 at 09:00 AM

RapetorJesus gravatar image

RapetorJesus
69

And what a glorious power it is!

I too share your enthusiasm. The rest of you can take your downvotes and pop-shuvit late backfoot kickflip.

Jun 27 '11 at 03:16 PM obsidian1269
(comments are locked)
10|3000 characters needed characters left

function OnTriggerEnter (other :Collider)
{ other.transform.parent = gameObject.transform; } function OnTriggerExit (other : Collider) { other.transform.parent = null; }

Here you go Full script. just attach this script to your emptyObject with triggered collider on it. but make sure the empty object is a child of the cube/platform who has the animation on it and this script goes to that child. and done. the character looks squeezed but if you have any solution please provide me one and i am working on it aswell.

more ▼

answered Nov 10 '12 at 09:59 PM

munaeem gravatar image

munaeem
81 1 5 8

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3460
x2086
x422
x410

asked: Mar 01 '10 at 03:06 AM

Seen: 30682 times

Last Updated: Feb 15 at 03:51 AM