RaycastHit hit;
float x = Random.Range(-spread, spread);
float y = Random.Range(-spread, spread);
float z = Random.Range(-spread, spread);
//Calculate Direction with Spread
Vector3 direction = Camera.transform.forward + new Vector3(x, y, z);
if (Physics.SphereCast(transform.position, Width, direction, out hit, Mathf.Infinity))
{
Hit_detection target = hit.transform.GetComponent<Hit_detection>();
if (target != null)
{
target.TakeDamage(damage, transform.name);
Instantiate(MissEffect, hit.point, Quaternion.LookRotation(hit.normal));
}
else if (target == null)
{
Instantiate(MissEffect, hit.point, Quaternion.LookRotation(hit.normal));
}
}
#unity spherecast has somehow missed
1 messages · Page 1 of 1 (latest)