Quantcast
Viewing latest article 26
Browse Latest Browse All 592

another problem with bullets

I have problem with my bullets It don't collision or something like that and It's writing this **ERROR** **Tag: Bullet is not defined. UnityEngine.StackTraceUtility:ExtractStackTrace () healthscript:OnCollisionEnter2D (UnityEngine.Collision2D)** **HERE IS VIDEO OF THE PROBLEM :** https://www.youtube.com/watch?v=62pFDRwY65w **HERE IS THE CODE** public string bulletTag = "Bullet"; public HealthBar healthBar; public int maxHealth = 100; public int currentHealth; // Start is called before the first frame update void Start() { currentHealth = maxHealth; healthBar.SetMaxHealth(maxHealth); } void OnCollisionEnter2D(Collision2D collision) { // Check if the object we collided with has the "Bullet" tag if (collision.gameObject.CompareTag(bulletTag)) { TakeDamage(20); } } void TakeDamage(int damage) { currentHealth -= damage; healthBar.SetHealth(currentHealth); }

Viewing latest article 26
Browse Latest Browse All 592

Trending Articles