What am i doing wrong (AI hiding system)

I’m doing an AI hiding system, I got no errors. I’m trying to switch the target to waypointer. When I switch the bool to false or true it won’t work.
am I doing it wrong or is there a other way to do it?

NavMeshAgent agent;
public Transform target;
public Transform waypointer;
public bool  hiding = true; 

void Start () 
{
	agent = GetComponent<NavMeshAgent> ();
}

void Update () {
	
	agent.SetDestination(target.position);
	if(hiding = false)
		waypointer = target;
		
	{
		if(hiding = true)

		
		target = waypointer;
	}
}

}

if(hiding = false)

is an assignment not a comparison. it should be

if(hiding == false)

or use the shorthand:

if(!hiding)

the code following that should probably be:

else
{
    target = waypointer;
}

but since it’s not entirely clear whether you always want to set it the other way round, that might not be the case :wink: