ok so ive tested this with a raycast and it works just fine but in an attempt to make the raycast bigger i switched to trying to use a spherecast after doing some studying i configured the script as follows but its not working. im guessing i have the syntax wrong or something but whats suppose to happen is that a spherecast happens forward from the player and if the target is in range damange is achieved. however i am not even receiving the print message so i know its not hitting anything.
void enemyisinrage()
{
if (Input.GetMouseButtonDown(0))
{
if (hastarget == true && GetComponent<Battler>().timerstart == true)
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
RaycastHit hit;
if (Physics.SphereCast(forward, 4.0f, Vector3.forward, out hit, Mathf.Infinity))
{
target.GetComponent<Battler>().takedamage(attackDamage);
target.GetComponent<EnemyControl>().takedamage(attackDamage);
print("there is something infront of the object");
}
}
}
}