Need some help finding an ORIO

finally finished working out the scripts for my fireball (rpg video 177) but the DealAreaDamage() keeps throwing a null reference. can someone help me by figuring out where my mistake is please!

private void DealAreaDamage()
            // TODO add method to choose a number of random targets up to the numberOfTargets
            foreach(Health target in GetTargets())
                Vector3 pos1 = transform.position;
                Vector3 pos2 = target.transform.position;
                int damageModifier = 1 - (int)Vector3.Distance(pos1, pos2);

        private Health[] GetTargets()
            Health[] targets = new Health[100];
            int arrayIndex = 0;
            foreach (Health candidate in FindObjectsOfType<Health>())
                float rangeToTarget = Vector3.Distance(candidate.transform.position, transform.position);
                if (rangeToTarget <= areaOfEffct) { targets[arrayIndex] = candidate; }
                if (arrayIndex > targets.Length) { break; }
            return targets;

Found the problem, I forgot to set areaOfEffect when instantiating the spell.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms