Initial Project Commit

This commit is contained in:
2025-10-27 17:26:17 +00:00
parent 36f31d54d1
commit bc21e94bc1
5 changed files with 48 additions and 41 deletions

View File

@@ -1,22 +1,39 @@
using UnityEngine;
using RPG.Movement;
using UnityEngine.Rendering;
namespace RPG.Combat
{
{
public class Fighter : MonoBehaviour
{
[SerializeField]
private float weaponRange = 2f;
Transform target;
private void Update()
{
if(target != null)
if (target == null) return;
if (!GetIsInRange())
{
GetComponent<Mover>().MoveTo(target.position);
target = null;
}
else
{
GetComponent<Mover>().Stop();
}
}
private bool GetIsInRange()
{
return Vector3.Distance(transform.position, target.position) <= weaponRange;
}
public void Attack(CombatTarget combatTarget)
{
target = combatTarget.transform;
}
public void Cancel()
{
target = null;
}
}
}