If I have a gameobject that is an instance of a given prefab, what Javascript would I use to switch it to a different prefab at runtime?
i used this in my explosivo entry (with a quality var in my main script):
var singularityBomb : GameObject;
var singularityBombLQ : GameObject;
function Awake ()
{
if (!MainCTRL.highQuality)
{
singularityBomb = singularityBombLQ;
}
}
yadda yadda ; )
I don’t get it then.
I’m doing exactly what you indicate (thanks, BTW) but the prefab is staying the same.
Note, though that I am doing it in the Update() function, since I need it to happen in response to a game event.
Your original question isn’t completely clear. Does the “old” prefab already exist in the scene, and you want to physically replace it? You need to destroy the old one and instantiate the new one in the same spot, and manually carry over any data from old to new.
Yes, SM, you nailed it.
In fact, I’ve already done what you suggested, based on the “ragdoll replace” code in the old FPS demo. I was just hoping there might be a simpler way to do it now that we’re at 1.6.2. Guess not.
Thanks, all!
sorry misunderstood the question ; )
NP, drjones.
Your reply was very much appreciated.