Trigger a Bool

Hello,

I have an endless runner game, after the player has reached a certain point, id like to trigger a Bool called “spawner” on or off in the component “Distance Spawner” attached to HillSpawner(gameObject), and turn Spawner Bool off, in the “Distance Spawner” attached to MushroomSpawner, rather than turning the gameobject itself on or off. The code below turns the entire gameobject on and Off, rather than the bool in the component. The current result is that the gameobject appears suddenly in the game at the specified moment.

Cheers

CSharp]using UnityEngine;
using System.Collections;
using MoreMountains.Tools;

namespace MoreMountains.InfiniteRunnerEngine
{
    public class ExampleScenario : ScenarioManager
    {
        public DistanceSpawner HillSpawner;
        public DistanceSpawner MushroomSpawner;
      



        protected override void Scenario()
        {
            AddScoreEvent(60f,()=>    SwitchToHillSpawner());
            AddScoreEvent(250f,()=>   SwitchToMushroomSpawner());
            AddScoreEvent(500f,()=>   SwitchToHillSpawner());
        }


        protected virtual void SwitchToHillSpawner()
        {
            HillSpawner.gameObject.SetActive(true);
            MushroomSpawner.gameObject.SetActive(false);
        }


        protected virtual void SwitchToMushroomSpawner()
        {
            HillSpawner.gameObject.SetActive(false);
            MushroomSpawner.gameObject.SetActive(true);
        }
    }
}

Thats because you are setting the game object active state it has nothing to do with the scripts attached to such game object. I’m not sure of the exacts names for your problem but try something like this: HillSpawner.gameObject.GetComponent<NameOfTheComponent>().nameOfTheBoolVariable = false.
You might also want to store the component in a variable for better performance.