Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

FindObjectWithhTag return only one GameObject

$
0
0
I have an array of GameObjects and I wanna get them with "FindGameObjectsWithTag" method.In my BaseEnemy class on start I change tag to "Enemy" and in result I get only one GameObject(instead of 3) public class BaseEnemy : MonoBehaviour { protected float max_speed; [SerializeField] protected float speed; protected float max_hp; [SerializeField] protected float hp; protected float max_damage; [SerializeField] protected float damage; protected Rigidbody2D rb; protected Controller controller; public GameObject enemy; private void Start () { enemy.tag = "Enemy"; controller = GameController.FindObjectOfType (); rb = GetComponent (); hp = max_hp; speed = max_speed; damage = max_speed; } } public class GameController: MonoBehaviour { public GameObject[] enemies; private void Start () { enemies = GameObject.FindGameObjectsWithTag("Enemy"); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>