Hello StriderSpinel.
I had the same problem during intros and outros in our game-project.
Here is my solution:
The idea is to create an additional layer which is not visible for the game-camera. During runtime you can move any gameobject (and it's children) to this layer to make them temporary invisible.
So at first create a new layer called "invisible" (layer #13 in my case):
Now setup the camera's culling mask to all layers except the new layer ("invisible" = 13).
Now you only have to move gameobjects to or from this layer.
Here is my solution for the intro-animation:
Open ControlScript.cs and add before
public void DoFixedUpdate( ....
this code:
void SetLayerRecursively(GameObject obj, int newLayer)
{
if (null == obj) return;
obj.layer = newLayer;
foreach (Transform child in obj.transform)
{
if (null == child) continue;
SetLayerRecursively(child.gameObject, newLayer);
}
}
This moves a gameobject and its children to a new layer.
Now change this:
else if (currentMove == null && ((playerNum == 1 && !introPlayed) || (playerNum == 2 && !introPlayed && opControlsScript.introPlayed))) {
CastMove(myMoveSetScript.intro, true, true, false);
}
to this:
else if (currentMove == null && ((playerNum == 1 && !introPlayed) || (playerNum == 2 && !introPlayed && opControlsScript.introPlayed))) {
CastMove(myMoveSetScript.intro, true, true, false);
SetLayerRecursively(opControlsScript.gameObject, 13); // hide opponent during intro
}
and to make the opponent visible again at the end of the intro-animation,
change this:
// Kill Move
if (move.currentFrame >= move.totalFrames) {
if (move.name == "Intro") {
introPlayed = true;
if (opControlsScript.introPlayed) UFE.CastNewRound(2);
}
to this:
// Kill Move
if (move.currentFrame >= move.totalFrames) {
if (move.name == "Intro") {
introPlayed = true;
SetLayerRecursively(opControlsScript.gameObject, 9); //make opponent visible after intro
if (opControlsScript.introPlayed) UFE.CastNewRound(2);
}
That's my solution and it worked for our game so far.
best regards,
shubi