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

Instantiate with healthbar dont work correctly

$
0
0
I have a problem with duplicating objects. I have enemies who spawn randomly with the amount of hp. The problem is that when there is more than one enemy and I will damage him hp is subtracted from every enemy instead of one. I have a standard hp script (HealthBar with SetMaxHealth and SetHealth attached to a slider and Enemy with maxhealth and currenthealth attached to the enemy). Also my script with spawn: public class RandomSpawn : MonoBehaviour { public GameObject myPrefab; public void Spawn() { Vector3 position = new Vector3(Random.Range(10.0f,- 10.0f), -1.55f, 0); Instantiate(myPrefab, position, Quaternion.identity); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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