i’ve done everything but the sword does not hit the enemy
edit: i needed 2 hours to figure out that i need to simulate the ridgidbody ![]()
here’s the enemy script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Illuminat : MonoBehaviour
{
public AudioSource oof;
public SimpleHealthBar bar;
public GameObject lupina;
[Header("health")]
public float MaxHealth = 40f;
private float currentHealth;
void Start()
{
currentHealth = MaxHealth;
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collider)
{
if (collider.tag == "Player")
{
GetHit(1f);
}
if (collider.tag == "Fuss")
{
GetHit(1f);
}
}
public void GetHit(float Hardness)
{
Debug.Log("got hit");
oof.Play();
bar.UpdateBar(currentHealth, MaxHealth);
if (currentHealth > 0)
{
lupina.transform.position = new Vector3(lupina.transform.position.x, lupina.transform.position.y - 10, lupina.transform.position.z);
currentHealth = currentHealth - Hardness;
}
else
{
lupina.GetComponent<UnityEngine.UI.Image>().color = Color.red;
Defeat();
}
}
public void Defeat()
{
//didn't add that yet
}
}