Question by
Keiseraaz · Oct 15, 2020 at 05:21 PM ·
2d game2d collision
Collision damage not working.
I'm making my first game. I try making a Angry Bird like game. Just to start easy. But I want to make a little twist that I take damage instead of killing the enemy in one hit.
using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.UI; public class MoonBoss : MonoBehaviour { public Slider slider; public Gradient gradient; public Image fill; public int maxHealth = 1000; public int currentHealth; public int damage = 100;
public void SetMaxHealth(int health)
{
slider.maxValue = health;
slider.value = health;
fill.color = gradient.Evaluate(1f);
}
public void SetHealth(int health)
{
slider.value = health;
fill.color = gradient.Evaluate(slider.normalizedValue);
}
private void TakeDamage(int amount)
{
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.collider.GetComponent<Bird>() != null)
{
TakeDamage(100);
}
}
}
What am I doing wrong? :(
Comment
I'm sorry that's hard to read. I'm not sure why not all the coding got in the same window.