x


Getting instance of an sub object rather than the original's subobject

How do you reference the instance of a subobject, as opposed to the subobject in the original object?

	var o:GameObject = Instantiate(growStick,coord,Quaternion.identity);
	var e:GameObject = o.Find("extender");

For some reason, the e reference always refers to the extender subobject in the original and not the clone.

When I try using: var e:GameObject = o.transform.Find("extender") as GameObject;, I get "NullReferenceException: Object reference not set to an instance of an object"

more ▼

asked Dec 31 '11 at 01:57 PM

ina gravatar image

ina
3.3k 492 550 602

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

0 answers: sort voted first
Be the first one to answer this question
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:

x2091
x1678
x1281
x426
x413

asked: Dec 31 '11 at 01:57 PM

Seen: 894 times

Last Updated: Dec 31 '11 at 02:00 PM