I've made a hitbox system with the following script
PlayerStatManager statManager;
public float hitboxRad;
private void Update()
{
RaycastHit2D hit;
CoreAliveObject alive;
hit = Physics2D.CircleCast(transform.position, hitboxRad,Vector2.right,0f,statManager.playerData.canHit); <-- This Line
hit.transform.TryGetComponent(out alive);
if (alive != null)
{
alive.TakeDamage(statManager.playerData.attack1Dmg);
}
}
private void OnDrawGizmos()
{
Gizmos.DrawWireSphere(transform.position, hitboxRad);
}
im trying to hit an enemy that inherites from CoreAliveObject and it is giving me a nullReferenceException on the highlighted line, ive tried everything and I cant figure out why it isnt working, any ideas?