So I have a monster that has this script attached to it and I want it to move after it kills the cannon, but it just stands there:
void Start()
{
speed = walkingSpeed
}
void Update()
{
transform.Translate(Vector3.right * speed * Time.smoothDeltaTime);
}
void OnTriggerStay(Collider col)
{
if (col.tag == "cannon")
{
attackingTimer += Time.deltaTime;
speed = 0.0;
if (attackingTimer > attacksEvery)
{
col.SendMessage("CannonTakesAHit", iDamage);
attackingTimer = 0.0f;
}
}
}
So basically hits the cannon over and over, but when the cannon dies, it stands there doing nothing, and I want it to keep moving forward.
I tried messing around with OnTriggerExit, speed = walkingSpeed with no success, I also tried adding else if col.tag != “cannon” it works but it takes random amount of seconds before it starts moving… which is not what I am looking for unless I can make it where it waits exact amount of time, every time, before moving. I also tried adding a send message in the cannon script where it sends hey this cannon is dead, keep moving and it works, but only for 1 monster, so if I have lets say 3 monsters attacking the same cannon, and they kill it only 1 of them starts walking and the rest stay behind.