Search Unity

So... i'm about to create Death...

Discussion in 'Getting Started' started by DerrickMoore, Jan 24, 2019.

  1. DerrickMoore

    DerrickMoore

    Joined:
    Feb 4, 2018
    Posts:
    246
    so I'm about to introduce "death" to my little universe..

    How should I do this?



    now, my game is an homage to the 80s games that I grew up with.. Dani Dunton's M.U.L.E., Bezerk, Lunar Lander, Captain Havok, Zaxxon, etc... set in a Buck Rogers/Flash Gordon "Ray-punk| universe.. .



    when my Player dies, I want to just play some animation or partical effect, then respawn at 0,0,0....

    I have some items that once the Player aquires will stay with them forever.. so "Death" wont effect the Player's inventory... Really, I want to world to stay the same after the Player gets killed, objects, enemies all in the same state (like if 7 out of 10 enemies were destroyed before the Player respawns, then after respawning there should be only 3 left.. so I'm not gonna re-load the level on Death or anything...

    Any help, suggestions, tutorials, thoughts on game Death.... would be really appreciated.. I'm not really a programmer.. I'm just a "script kiddy" at best, but I have been making games for a long time...



    how does the Player die? most likely from colliding with an object like an asteroid or an enemies instatiated projectile..

    Death script should go on the Player, seperatly, or should I include death in the Player movement script?

    Ideally, "Death" would be an AI personification hidden somewhere in my world, that could make mistakes, and even "ignore" or overlook a Player death, if it's busy.... like,,, hmm, Player just killed 15 enemies in some second, but gets killed too, but my Death would be kinda stupid and can only "be aware" of like the first 9 "deaths" that happen in one second... (yes, it would make the Player an invincible whirlwind of death if they can keep with the numbers... a reward for massive combos?)..
     
  2. DerrickMoore

    DerrickMoore

    Joined:
    Feb 4, 2018
    Posts:
    246


    well... it's not pretty but it works..

    Code (CSharp):
    1. public class asteroidkill : MonoBehaviour
    2. {
    3.     public GameObject Asteroidexplosion;
    4.  
    5.  
    6.     void OnTriggerEnter(Collider other)
    7.     {
    8.         // Debug.Log(other.name);
    9.         // rock so will not kill other rock asteroids
    10.  
    11.         if (other.tag == "Rock")
    12.         {
    13.             return;
    14.         }
    15.  
    16.         if (other.tag == "Lander")
    17.         {
    18.             return;
    19.         }
    20.  
    21.         // if rock hist a planet, will cause an explosion and destroy the rock.. but not the planet...
    22.  
    23.  
    24.         Asteroidexplosion = Instantiate(Asteroidexplosion, transform.position, transform.rotation);
    25.         if (other.tag == "Planet")
    26.         {
    27.             Asteroidexplosion = Instantiate(Asteroidexplosion, other.transform.position, other.transform.rotation);
    28.           Destroy(gameObject);
    29.           //  Destroy(other.gameObject);
    30.  
    31.         }
    32.  
    33.         Destroy(other.gameObject);
    34.        // Destroy(gameObject);
    35.     }
    36. }

    so.. if I can get the tags to work right... (I'm confused over "Gameobject vs other.gameobject)… I will make a Player tag, that will instantiate a player explosion that puts a big "Game over" on the screen....

    but.... and I think this is a "logic" problem.. and I'm not so good at Logic... I'm a "heart rules my head artist"

    so this script is on the Asteroid... there 3 tags in my world.. Rock (asteroids) Planet (surface of planet) and Lander (a thing that cant be destroyed from contact with an asteroid or planet... landing gear, etc...

    so, if the Asteroid Rock makes contact with the Planet surface (planet tag) I want the Rock destroyed, instatiate an explosion prefab... but I want the planet to stay there... right now, my planet is getting destroyed too...

    so.. on the Asteroid script... the asteroid is "gameobject" and the planet is "other.gameobject"?
     
    Last edited: Jan 30, 2019
  3. DerrickMoore

    DerrickMoore

    Joined:
    Feb 4, 2018
    Posts:
    246
    ahh, Jeeze, did I offend someone or something?

    but, I see now.. I had commented out that bit of the code which would have answered my question... I couldn't see that until I read through my code here, instead of in VS....

    "Artist's blindspot" we called it in school... we have a tough time seeing our own mistakes..

    . I have sooo not been properly using the console...

    in the last 5 mins, the console has been so helpful... I've spent the last year just stepping through the game diagnosing bugs... in fact, this is the first time I've run my game without a bunch of Red Text showing up... I feel kinda silly

    also, the Earth is beautiful today
    http://www.ustream.tv/channel/iss-hdev-payload
     
    Last edited: Feb 1, 2019
    JeffDUnity3D likes this.