private void Interact() { if (System.DateTime.Now > nextAttack) { Debug.Log("Interact attempt"); RaycastHit hit; if (Physics.SphereCast(this.transform.position, 1f, this.transform.forward, out hit, 2f)) { Entity targetEntity = hit.transform.GetComponent <Entity>(); Debug.Log(targetEntity); if (targetEntity != null) { Debug.Log("Entity found attempting to interract"); if (targetEntity.action_id >= 0) { Debug.Log("Actionid found"); ActionHandler.EntityAction(targetEntity.action_id)(this); } } nextAttack = System.DateTime.Now.AddMilliseconds(attackDurationInMs); } } }