#unity spherecast has somehow missed

1 messages · Page 1 of 1 (latest)

toxic rapids
#
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));
                }
            }
#

x y z all equal 0 so their shouldnt be any spread

#

ive also tried not factoring it in at all but that made no difference

#

i also made width 0 just in case that was the issue