Make it so if another follower starts following you, the one currently following stops?

This is what i have:

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
	public GameObject HumanFollower;
	public GameObject AlienFollower;
	public GameObject RobotFollower;
	public GameObject MonsterFollower;

	private bool HumanFollowerStateGet;
	private bool AlienFollowerStateGet;
	private bool RobotFollowerStateGet;
	private bool MonsterFollowerStateGet;

	// Use this for initialization
	void Start () {
		HumanFollowerStateGet = HumanFollower.GetComponent <Follower> ().Following;
		AlienFollowerStateGet = AlienFollower.GetComponent <Follower> ().Following;
	// Update is called once per frame
	void Update () {
		if (HumanFollowerStateGet == true)
			if (AlienFollowerStateGet == true)
				AlienFollowerStateGet = false;

will this work if i do it for all of them? If not, how will I make it work?

No, bools are VALUE types, just like ints were the last time you asked this question. Your Get variable strategy will never work for value types. This is really basic stuff, and if you don’t get it (which is cool, we were all new once) you really really REALLY need to read some stuff and get it pounded into your head. It’s important.

Instead, you could do something like:

 private Follower Follower_Human;

 Follower_Human = HumanFollower.GetComponent<Follower>();
 Follower_Human.Following = true;

Your approach itself will, technically, work if you do it like that, but it’ll be kind of a nightmare to maintain. You’ll need x^2 if statements. One way you could help that is to realize that you don’t actually care if you’re setting a false value back to false. eg.

 if (Follower_Human.Following)
    Follower_Alien.Following = false;
    Follower_Robot.Following = false;
    Follower_Monster.Following = false;

This is better, but you’re still going to be duplicating code. If you don’t have any triggers on Following changing state, you could move on to:

if (Follower_Human.Following)
   Follower_Human.Following = true;

Really, though, you shouldn’t be doing this in Update at all, you should be doing this when, and only when, a new follower starts following. Update is probably the worst place to put code, but most new coders put everything there. Something to watch out for.

A dissertation on event driven programming or delegates and events in C# is well beyond the scope of this QA, but you may want to look into them.

Here is some more code. I am determined to help you get this. Making it an answer, because its long enough to stand by itself. As written it will change the follower every two seconds. But you get the idea.

// This should be present on every follower
public class Follower : MonoBehaviour {
    public bool isFollowing;

    void Update (){
             Debug.Log("I'm Following :" +;


// This should exist once and only once
public class FollowerManager : MonoBehaviour {
    private Follower currentFollower;

    public void ChangeFollower (GameObject newFollower){
            currentFollower.isFollowing = false;
        currentFollower = newFollower.GetComponent<Follower>();
        currentFollower.isFollowing = true;

    // Some random code to change the follower. Change to suit your game
    private float timer = 0;
    private int index = 0;

    // Add the required number of followers via the inspector
    public GameObject[] followers;

    void Update (){
        timer += Time.deltaTime;
        if (timer > 2){
            ChangeFollower (followers[index]);
            timer = 0;
            index ++;
            if(index >= followers.Length) index = 0;


Edit: Since you are having trouble implementing this here is a Unity Package that contains an implementation of my scripts. You are free to use however you like.