- Home /
Question by
firassoudeni · May 11 at 12:48 PM ·
script.unity 2d
Enemy AI script works Only on 1 Player From my 2Player Game
Hello fellow game devs , i have a problem in my game . i have a AI script that has this Function to Attack : public void Attack() {
Collider[] EnemiesInRange = Physics.OverlapBox(transform.position, AttackBoxRange, Quaternion.identity, Player_Layer);
foreach (Collider enemy in EnemiesInRange)
{
enemy.GetComponent<Character_Manager>().TakeDamage(Damadge);
}
}
And i use a Cooldown as a If statment wich goes like this :
if (TimeCounter <= 0) { Attack(); TimeCounter = TimeBetweenAttacks; } else TimeCounter -= Time.deltaTime; } Problem Is , it only works on 1 Player , the other one gets oneshooted in a split second.
Comment
Your answer
Follow this Question
Related Questions
How do I access a script from a class inside a script. 1 Answer
Object disappears on running 1 Answer
Which is best for optimization 1 Answer
how to make scripts show gizmos in the Gizmos menu? 1 Answer
Unity2D resize the sprite 0 Answers