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

Get position of prefab enemy ?

$
0
0
Hello, I have a prefab of enemies who spawn regularly. I try to get the position of them in order to kill them. It work with the one already instanciate but not the new. First I get the gameobject and the position from the enemy script: public GameObject Foe = GameObject.Find("o_foe"); public float PosXFoe; public float PosZFoe; Then: void Start() { Foe = GameObject.FindGameObjectWithTag("Foe"); FoeHealth = Foe.GetComponent(); } void Update() { PosXFoe = GameObject.Find("o_foe").GetComponent().PosXFoe - 2; PosZFoe = GameObject.Find("o_foe").GetComponent().PosZFoe - 2; } And the attack: void GestureAttack() { if (recupgeste == "D" && recupgestescore > 0.50) { player.transform.position = new Vector3(PosXFoe, 1, PosZFoe); if (FoeHealth.currentHealth > 0 /*attackphas*/) { // ... damage the player. FoeHealth.TakeDamage(attackDamage); } } } Help me, thanks.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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