void OnTriggerExit2D(Collider2D coll) { TargetWalker targetWalker = coll.gameObject.GetComponent <TargetWalker>(); if (targetWalker) { targetWalker.td_speedCoef /= speedCoefficient; } }
// Collisions void OnTriggerEnter2D(Collider2D coll) { if (numberOfCollisions > 0) // Only trigger warning for first entry. { return; } TargetWalker targetWalker = coll.gameObject.GetComponent <TargetWalker>(); if (targetWalker) { int arrivalTime = (int)((collider.bounds.extents.x / 2.0) / targetWalker.m_speed); TriggerWarning(arrivalTime); numberOfCollisions++; } }