x


static gameobject

i have a script on one object, the script is called "Manager"

static var share : GameObject;
var obj : GameObject

function Update () {
      share = obj
}

then another script on another object to instantiate.

var object : GameObject;

var spawn = Instantiate(object ,Manager.share.transform.position,Quaternion.identity);
object.transform.parent = Manager.share.transform;

but it doesn't seem to work :/ any ideas? thanks

more ▼

asked Jul 29 '12 at 05:26 PM

oinkoinkflapflap gravatar image

oinkoinkflapflap
193 42 54 66

i'll add the object with the second script is instantiated at runtime itself and the "share" object is in the scene from the start as is the object containing the first script

thanks

Jul 29 '12 at 05:29 PM oinkoinkflapflap

check for null 'Manager.share' before instantiating.

and... what does it mean - 'doesn't see to work'?

Jul 29 '12 at 05:36 PM ScroodgeM

how are you calling the Instantiate? is that inside a function?

Jul 29 '12 at 05:41 PM Seth Bergman
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

A static game object? Just search and find the object. Here I assume the GO is named Share:

var object : GameObject;
var share:Transform;

function Start(){
share = GameObject.Find("Share").transform;
}

var spawn = Instantiate(object ,share.transform.position,Quaternion.identity);
object.transform.parent = share.transform;
more ▼

answered Jul 29 '12 at 05:36 PM

fafase gravatar image

fafase
10.5k 9 15 41

(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:

x2087
x1674
x1278
x823
x277

asked: Jul 29 '12 at 05:26 PM

Seen: 473 times

Last Updated: Jul 29 '12 at 05:41 PM