When this happenas, I would like to:
- change color os screen to blue
- stop the controls of FPC
- change position of FPC to the original coordinates
- reset all the game (animations, GUIs, etc)
Any help?
Thanx
When this happenas, I would like to:
Any help?
Thanx
It is very difficuilt to give you exact ideas, because it depend a lot on your game structure, but here are some thoughts:
But once again, this very much depends on the way that you have planned and structured your game
Dying on ~1.27 minute:
Somewhere in your damage script!
function Die () {
// Disable all script behaviours (Essentially deactivating player control)
var coms : Component[] = GetComponentsInChildren(MonoBehaviour);
for (var b in coms) {
var p : MonoBehaviour = b as MonoBehaviour;
if (p)
p.enabled = false;
}
yield WaitForSeconds(2.0);
LevelLoadFade.FadeAndLoadLevel(Application.loadedL evel, Color.black, 2.0);
}
/*
Usage:
// Load my level
LevelLoadFade.FadeAndLoadLevel("mylevel", Color.white, 0.5);
// Reset the current level
LevelLoadFade.FadeAndLoadLevel(Application.loadedL evel, Color.white, 0.5);
*/
static function FadeAndLoadLevel (level, fadeTexture : Texture2D, fadeLength : float)
{
if (fadeTexture == null)
FadeAndLoadLevel(level, Color.white, fadeLength);
var fade = new GameObject ("Fade");
fade.AddComponent(LevelLoadFade);
fade.AddComponent(GUITexture);
fade.transform.position = Vector3 (0.5, 0.5, 1000);
fade.guiTexture.texture = fadeTexture;
fade.GetComponent(LevelLoadFade).DoFade(level, fadeLength, false);
}
static function FadeAndLoadLevel (level, color : Color, fadeLength : float)
{
var fadeTexture = new Texture2D (1, 1);
fadeTexture.SetPixel(0, 0, color);
fadeTexture.Apply();
var fade = new GameObject ("Fade");
fade.AddComponent(LevelLoadFade);
fade.AddComponent(GUITexture);
fade.transform.position = Vector3 (0.5, 0.5, 1000);
fade.guiTexture.texture = fadeTexture;
DontDestroyOnLoad(fadeTexture);
fade.GetComponent(LevelLoadFade).DoFade(level, fadeLength, true);
}
function DoFade (level, fadeLength : float, destroyTexture : boolean)
{
// Dont destroy the fade game object during level load
DontDestroyOnLoad(gameObject);
// Fadeout to start with
guiTexture.color.a = 0;
// Fade texture in
var time = 0.0;
while (time < fadeLength)
{
time += Time.deltaTime;
guiTexture.color.a = Mathf.InverseLerp(0.0, fadeLength, time);
yield;
}
guiTexture.color.a = 1;
yield;
// Complete the fade out (Load a level or reset player position)
Application.LoadLevel(level);
// Fade texture out
time = 0.0;
while (time < fadeLength)
{
time += Time.deltaTime;
guiTexture.color.a = Mathf.InverseLerp(fadeLength, 0.0, time);
yield;
}
guiTexture.color.a = 0;
yield;
Destroy (gameObject);
// If we created the texture from code we used DontDestroyOnLoad,
// which means we have to clean it up manually to avoid leaks
if (destroyTexture)
Destroy (guiTexture.texture);
}
Hi chubbspet. Thanks for the answer.
Can I animate this GUI (FADE IN) in the animation panel?
I don´t know how can I do it in the script
Any refence about it?
My game has a only level. Anyway to restart the game when the player dies without care with each details?
Hi badbii,
Nice game. Congrats.
But I don´t how to implement this in my game.
Tx.
2)You can call the player controller script with something like GetComponent("PlayerControllerScript’).active = false; I recommend reading about the GetComponent method, you are going to use it overtime
4)For the last one, you can create a second scene called loaderScene. In that scene, create a script called myLoader and in the Start even of myLoader script place some code that would load your original scene using the application.loadlevel. Now when your player has died and you want to reload the game, just call your loaderScene and it will unload your current, reload the loader and reload your game from the start.
hope this helped