x


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.

more ▼

asked Jul 20 '11 at 01:10 PM

Xatoku gravatar image

Xatoku
152 73 81 88

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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;
more ▼

answered Jul 20 '11 at 02:42 PM

Sarper Soher gravatar image

Sarper Soher
1.6k 1 4 16

And in the switch it will go too fast for anything to notice?

Jul 20 '11 at 03:30 PM Xatoku

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.

Jul 20 '11 at 03:35 PM fffMalzbier

This would probably be the best solution

Jul 20 '11 at 04:20 PM J3 Gaming
(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:

x1682
x1281
x1260
x1047
x764

asked: Jul 20 '11 at 01:10 PM

Seen: 580 times

Last Updated: Jul 20 '11 at 04:20 PM