Search Unity

Problem with respawn heroes

Discussion in 'Scripting' started by uneexpff, Feb 21, 2018.

  1. uneexpff

    uneexpff

    Joined:
    Dec 12, 2017
    Posts:
    5
    hello guys, i have some kind of Tower Defence game and one problem with respawn heroes:

    I have a spawn place(cube) with cript OnMouseDown() wich creating a hero on this cube, and also the script that respawn that hero on this cube everytime the enemy's wave is over.

    I have a hero with script OnMouseDown() wich creating a PANEL with 2 different Buttons "Upgrade" and "Sell", and if u press the Upgrade button the hero will be destroed and new hero gameobject will be instantiated on the same place.

    So the problem starts after the end of the enemy's wave so the cube respawn script instantiating the old version of hero and the second problem happens when we had to sell the hero, but the respawn script
    continues to work and respawning it.

    The problem is that we have much of the cube's and a lot of hero's and i dont know how to tie the cube with the hero, i believe you understand me, btw sorry for my bad english. Help please))
     
  2. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    You'll have to show some of the code where you respawn the new hero.
     
  3. johne5

    johne5

    Joined:
    Dec 4, 2011
    Posts:
    1,133
    It sounds like the upgrade functions needs to have some code added to it. Before you destroy the basic hero, you need to update the data in the respawn script. the hero object need to be changed to the new upgraded hero.