- Home /
Problems with cloned prefabs
Hello :)
I have some problems with the interaction of/between cloned objects.. When I destroy my enemy prefab it instantiates a clone or some clones (Random.Range) of the magicOrb prefab.
I've been trying to get these orbs to interact with my character, but somehow I can't get them to interact :( I can't drag'n'drop my player object in the inspector of my prefab, the orb prefab can't find my "find object with tag" for some strange reason, and even if I turn the system around and let the script attached to my player character interact with the GameObject magicOrb they simply won't work :(
Is it a common problem/bug with Unity 3?
BTW I have a really strange error every time the debugger pops up:
" classID >= ms_MaxClassID || classID < 0 "
Shows as an error, but it builds and plays just like normal.
Could this have anything to do with it?
Thanks in advance :)
GameObject.FindGameObjectsWithTag works just fine in Unity 3, so the problem is likely that the problem is either you are looking for the wrong tag or the tag is not on the "Player" object.
What error are you getting?
Would be helpful if you could post your "interact with the orb" script and also, what error you are getting on that script. Im not sure on the classID error, never had that myself.
Answer by entrapped89 · Sep 20, 2011 at 02:08 PM
Thanks for replying :)
My AddMagicPointsScript:
var magicPointsAdd : int = 10;
function Awake () { var player = GameObject.FindWithTag("Player"); }
function OnTriggerEnter (player : Collider) {
var myScript : MagicScript = FindObjectOfType(MagicScript); myScript.magicCount += magicPointsAdd; Debug.Log ("You have the item!"); Destroy (gameObject, 1); }
I attached the script to the "triggerzone" trigger object. Even when I copy an instance of the object in the editor it does not work..
Somehow the moment the object (or it's clones) touches the terrain mesh the script triggers the effect! I'm 100% sure I have added the Player tag to my FPS controller..
I'm at a loss :P
What am I doing wrong?
Thanks in advance :)
O$$anonymous$$G :P I added this text as an answer.. I'm not that good at blogging.. :P sorry moderators :P
Your answer
![](https://koobas.hobune.stream/wayback/20220612220309im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Cloned Prefab 3 Answers
Instatiating an object. Altering that new object causes prefab to be altered. 2 Answers
Instantiated Object turning off scripts and audio source?(Solved) 1 Answer
OnTriggerEnter2D not working on sprite's prefab clones 0 Answers
How to destroy a clone (instantiate in scene) in the their own script 1 Answer