|
Hi guys ! I have a problem that i cant resolve myself ! Im working on a tower defense, i have my first tower done with its script, works perfectly. Im using a List to put de ennemies of the wave in. The problem is when i make a second tower ( the same as the first ) it doesnt get the ennemies in the List. They only go in the first tower's script. I dont know why it doesnt work for the same tower...! I hope one of you can resolve this ! Thanks ! Here's my code using UnityEngine; using System; using System.Collections; using System.Collections.Generic; public class RangedAttackAllied : MonoBehaviour { public List targets; }
(comments are locked)
|
|
I suggest you create a GameManager class that's attached to an empty game object. Use this to store the enemies in a List. When you instantiate your tower just get the enemy list from the GameManager class.
(comments are locked)
|

To be clear - when you add the script to the second tower are you also setting the list of targets in that one? Or are you wanting the one list to be available to both of the towers?