Notice our update method
void Update()
{
bool isInRange = Vector3.Distance(transform.position, target.position) < weaponRange;
if(target != null && !isInRange)
{
GetComponent<Mover>().MoveTo(target.position);
}
else
{
GetComponent<Mover>().Stop();
}
}
PLEASE notice how we check for a null target one line LATE!
something is just not feeling correct here.
We were careful to check that we had a target… two lectures later now we create a bool using a target that could be null!
I am confused please help me get it.
Why check for target != null… for the getcomponent but NOT for the bool???
Thanks
Oh yea I forgot to mention my player doesn’t even move now because of this target not being set.