Invoke method not being called for unknown reason, used a Coroutine as well - no difference.
The function gets performed if I just straight out call it ( Example : FreezeZombies(); ) but if its either a Coroutine or an Invoke, which I need because I need a short delay, It just never gets called?
using Power;
using System.Collections.Generic;
using UnityEngine;
public class TeslaProjectile : Projectile
{
[Header("Tesla")]
[SerializeField] private ParticleSystem teslaInfectedParticles = null;
[SerializeField] private float zombieFrozenTime = .2f;
private List<UndeadHealth> undeadHealthsToShock = new List<UndeadHealth>();
protected override void GrabSplashDamageEntitys(Collider[] splashHits)
{
base.GrabSplashDamageEntitys(splashHits);
foreach (Collider c in splashHits)
{
if (c.TryGetComponent<PoweredObject>(out PoweredObject poweredObj))
{
if (poweredObj.poweredByElectricBursts)
{
poweredObj.TurnPowerOn();
}
}
if (c.TryGetComponent<UndeadLimb>(out UndeadLimb hitLimb) && hitLimb.GetComponentInParent<UndeadHealth>())
{
UndeadHealth _health = hitLimb.GetComponentInParent<UndeadHealth>();
if (!_health.isInDeathState && !undeadHealthsToShock.Contains(_health))
{
undeadHealthsToShock.Add(_health);
if (_health.TryGetComponent<Zombie>(out Zombie zmb))
{
zmb.isAllowedToDealDamage = false;
worldFunctionManager.SpawnParticle(teslaInfectedParticles, _health.thisEntity.GetEntityPosition(), true);
}
}
}
}
Invoke(nameof(FreezeZombies), zombieFrozenTime);
}
private void FreezeZombies()
{
if(undeadHealthsToShock.Count <= 0) return;
foreach(UndeadHealth health in undeadHealthsToShock)
{
health.TakeDamage(damage, ef, health.thisEntity.GetEntityPosition());
if (health.TryGetComponent<Zombie>(out Zombie zmb))
{
zmb.isAllowedToDealDamage = true;
worldFunctionManager.SpawnParticle(teslaInfectedParticles, health.thisEntity.GetEntityPosition(), true);
}
}
}
}