Long story short. Trying to create a clone of a game called “Orcs Must Die” and trying to update all the orc clones’ scripts. Basicly the orcs check to see if the gate is up or down, If gate is up then attack gate if gate is down keep moving. While they do do this. If they spawn while the game is up, They will attack the gate wither its up or down for the rest of existence. only the newly pawned orcs will have regersted in their mind the gate is down. Here is what I got so far.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class gateBehavior : MonoBehaviour
{
//Wall Stats
public float maxHealth = 20f;
public float Health = 20f;
public string thisName= "";
public TilemapRenderer tba;
public TilemapRenderer tbb;
public OrcBehavor ocb;
public GameObject[] Orcs;
void Start()
{
//Sets Stats
Health = maxHealth;
}
void Update()
{
if (Health <= 0) //When Wall is broken
{
print("Gate Destoryed");//Checkpoint for me to know the code made it this far
if (thisName == "GateA")//There are 2 exsisting gamtes. This is for gateA
{
tba.enabled = false;
Orcs = GameObject.FindGameObjectsWithTag("Orcc"); //Checks for all exsisting Orcs with the tag "Orccs. This includes the clones"
foreach (GameObject orc in Orcs)
{
ocb = GetComponent<OrcBehavor>();
ocb.gateAUp = false;
}
}
if (thisName == "GateB")//And this for Gate B (More to exsist in the later game)
{
tbb.enabled = false; //WIP Gotta finish gate A first
ocb.gateBUp = false; //WIP
}
}
}
public void TakeDamage(float damage) //When Hit
{
Health -= damage;
print("Bonk"); //When Hit say Bonk, A Checkpoint for me to know the code made it this far
}
}