- Home /
Destroying & Then Spawning Quickly
I'm thinking about how I'll do a transformation which would involve a Character Prefab switching with Another Character Prefab, but done so in a way it looks like the Play Prefab transformed, and I'm curious if I switch them quick enough will any scripts trying to reach them be affected or will they just find the new one?
Example:
Destroy(Player1)
Instantiate(Player2)
Obviously they'd be a little more in depth but is this possible or do I have to create a variable saying that if they're switching than don't look for them? Hard to explain I know but if I got through to anyone please tell me if it's possible.
Answer by SarperS · Jul 20, 2011 at 02:42 PM
You can keep the prefabs under the same parent object and enable disable them based on the mechanics you want.
var player1 : GameObject;
var player2 : GameObject;
player1.active = false;
player2.active = true;
And in the switch it will go too fast for anything to notice?
if both player looks the same nobody will see it. is a fast action to enable or disable a game-object. You have to take a look in your start() and Awake() function so that if the player is enabled he does not need some extra time to initialize.