Hi All,
I am having trouble with the following:
I have a small army of 100 soldiers. The player can cast a shield on top of those soldiers. The shield is a big sphere that when entered, sends the troops a message that they are shielded. On Exit the shield sends the soldiers the opposite message. It works fine for one thing. If the soldiers are stationary and I spawn the shield, the collision is not detected. If I then move the soldiers, it is detected. I tried scaling the shield, but that the problem stays the same. Same thing when the shield shrinks: the collision is not detected when the soldiers are stationary. Is there any way to fix this? I have included the code on the shield.
//this script handles the effects of the AoE shield
private var shrink : boolean;
function Start ()
{
yield WaitForSeconds(5);
shrink = true;
Destroy(this.gameObject, 3);
}
function Update()
{
if(transform.localScale != Vector3(100, 100, 100) !shrink)
{
transform.localScale = Vector3.Lerp(transform.localScale, Vector3(100, 100, 100) ,Time.deltaTime);
}
if(shrink)
{
transform.localScale = Vector3.Lerp(transform.localScale, Vector3(0,0,0),Time.deltaTime*2);
}
}
function OnTriggerEnter(other : Collider)
{
if(other.tag == "Soldier")
{
other.GetComponent(troopScript).ActivateAOEShield();
}
}
function OnTriggerExit(other : Collider)
{
if(other.tag == "Soldier")
{
other.GetComponent(troopScript).DeactivateAOEShield();
}
}