Hi, I like the changes you made. I was wanting to do the same for the combat. I was wondering if you can help with this problem I have I can’t tell want I’m doing wrong in the code. I keep getting a null reference but the print statement still comes through but I don’t know why the null comes up.
namespace RPG.Combat
{
public class TPHitBox : MonoBehaviour
{
public Collider trigger;
public Weapon weaponObject;
TPFighting tpFighting;
GameObject enemytarget;
private void Awake()
{
tpFighting = GetComponent<TPFighting>();
enemytarget = GameObject.FindWithTag("Enemy");
}
void Start()
{
trigger = GetComponent<Collider>();
if (trigger)
{
trigger.isTrigger = true;
// trigger.enabled = false;
}
}
void OnTriggerEnter(Collider other)
{
if (weaponObject.friendly == true && other.gameObject.tag == "Enemy")
{
print("Hit Enemy");
tpFighting.Attack(enemytarget);
}
if (weaponObject.friendly == false && other.gameObject.tag == "Player")
{
print("Hit Player");
}
}
}
}
tpFighting.Attack(enemytarget); comes up null
public void AttackBehaviour()
{
GetComponent<Animator>().SetTrigger("Attack");
print("Attacking");
GetComponent<Stamina>().AttackCost();
tPControlUI.Lock(true, true, true, 0, .75f);
}
public void Attack(GameObject combatTarget)
{
target = combatTarget.GetComponent<Health>();
Hit();
print("Hello!!!!!");
}
Hope there is something you may be able to tell what’s wrong, thanks.