Prefab / object clone problem - repost

Hi all,

I’ve already posted this to the script forum, but since I’m encountering this in the iPhone verion of Unity, I thought I’d repost here and see if anyone here has any thoughts.

Ok, I’m stumped! I have a gameObject hierarchy that has 2 sub game objects (normally, 2 levels deep in the object chain) that !) won’t attach if I create a prefab and drop the gameObject into it, or 2), if I try Instantiate to clone the object they don’t copy. I have no idea why??!!

I’ve tried moving the object up the parent chain until they are right below the source gameObject, and … nothing!

Has anyone encountered a problem like this or have any idea what could be happening??

For reference purposes, I’m using the iPhone version of Unity when this is happening, but I’m posting here because this seems like a more general type problem. (Correct me if I’m wrong :slight_smile: )

[edit/update]
Ok, so to add to this, it appears to be possible to create a specific prefab for the 2 sub-objects in question, I just can’t seem to make them elements of another prefab. Is there some setting or script reference that would make a gameObject limited to a top level of a prefab, or explicit addition to a gameObject hierarchy?

Thanks,

Galen

Galent:

I’m a little confused about what you are trying to do.

Prefabs are unfortunately a bit wonky and don’t actually do what you want them to do.

e.g.: I find that if you make a prefab out of other prefabs, you cannot edit the sub-prefab and at the same time it loses its link to the original prefab - so if you update the original prefab, the iteration now a sub-prefab in a new prefab does not update.

Annoying.

You’d expect to be able to make prefabs - say particle flames and incorporate them as one of several other prefabs into another parent prefab - say engineVFX which includes interactive lights as another prefab, perhaps even put this prefab (containing a particle prefab and a lighting prefab) into an enemy ship prefab… and be able to tweak the original flame prefab and have it propagate into the new enemy ship parent prefab by updating the child particle flames.

It doesn’t.

And you can’t edit the - now orphaned - flame sub-prefab. Your stuck with your original settings, or rebuilding the entire prefab.

Not a great way to use prefabs, no?

In the end it seems that Unity likes to think of prefabs as a final finished piece of artwork that you need to instantiate multiple times, rather than as a publish-subscribe method of asset management.

Could this be related to what you are trying to do?

Or can you try to make my thick head understand?

Hi Little Angel,

while I have tried making several prefabs and combining them to solve this, it isn’t the actual problem. I have a gameObect I’d like to clone over and over at runtime, the object has 3 sub-objects, and each sub-object has 1-5 sub-objects themselves like this:

gameObject
-sub1
—subOfsub
—subOfsub2
-sub2
—subOfSub2a
—subOfSub2b
—subOfSub2c
— subOfSub2d

and so on, the problem seems to be with the sub object that has 5 attached gameobjects, both clone and prefab only seem to want to recognize 3 of the 5, no matter how I approach the problem. At first it appeared that the problem might be some kind of strange limitation on the number of sub elements that Unity would recognize, so I moved the objects that won’t clone up the tree. Nothing :frowning:

The only unique quality I can see is the objects that don’t clone have rigidbodies attached, like the root parent object. Other than that I’m at a loss.

Was that clearer?

Any ideas?

Thanks,

Galen

Galent:

I can’t get this to duplicate.

Take a look at the attached project and let me know what I’m missing…

I can’t seem to update this project. I keep getting the error “no post mode specified”…

I’ll try again in a new post.

Trying to update this post…

I’d made the original project based on your diagram, not your post, and only had two sub-groups.

Here is the original project… and I’ll try to get the larger one posted.

Still can’t replicate the problem…

150606–5490–$instantiate_prefab_project_352.zip (1.62 MB)

Thanks for all your help Little Angle :slight_smile:

As it turns out (all too often :wink: ) the problem was mine. The objects in question are scripted to explode on collision. Now in the base gameobject and in the prefab those objects were disabled, but on clone, they spawned … enabled and… BOOM! Heh heh.

Which is why they didn’t appear to be in the cloned object tree during runtime. I was just about to turn my attention back to that problem last night, when during a last test of another function I noticed a explosion flash from the position of a new clone.

Oh well, such is the danger of midnight coding :roll:

Thanks again!

Galen