Hello there.
Long story short, I’ve written a script that replicates tunnel segments as the player moves through them to generate a stretch of tunnels in which no more than eight segments are ever spawned at any one time. This part of the script works fine. Now I’m working on a way to stop the replicating, upon the player passing through a ‘Tunnel Stopper’ object, so that the tunnels will no longer generate copies of themselves upon collision.
Here is the code for the trigger attached to the Tunnel Stopper object:
static var tunnelsInProgress : boolean = true;
function OnTriggerEnter (trigger : Collider)
{
if(trigger.gameObject.name == ("Player"))
{
tunnelsInProgress = false;
}
}
And here is the segment that is supposed to receive and pause the script, attached to the tunnels themselves.
function Update ()
{
if(StopTunnel.tunnelsInProgress == false)
{
this.enabled = false;
Debug.Log("Blah");
}
}
Originally, I tried to simply find and reference the object from the trigger script, but I ran into endless issues with something or another, so I went back to a system which I know is fool proof; sending a boolean call from the trigger to the receiver.
My Debug Log is giving me the “Blah’s”, in fact it’s giving me no more than nine of them. I can also see in the hierarchy that the scripts that I am trying to deactivate are (all of them) deactivated, upon the player’s collision with the trigger. And yet, the tunnels continue to duplicate themselves.