Unity2D Need Help in Multiple Enemies Shooting Script
Hello Guys,
I am new to unity and i am having some problem with my enemy script, i made my enemy in a way that it has a trigger collider attached to it and it my player comes into the trigger the enemy shoots the player. Unfortunately, when i have only one instance of my enemy everything works great, but when i duplicate my enemy they do nothing (they walk fine but not shoot player).
Here are my scripts: Script for Enemy Finding player
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class OctrokFindingPlayer : MonoBehaviour {
 
 public bool playerInSight;
 
 public void OnTriggerEnter2D (Collider2D other)
 {
  if(other.gameObject.tag == "Player") {
 playerInSight = true;
  }
 }
 
 public void OnTriggerStay2D (Collider2D other){
 if(other.gameObject.tag == "Player") {
 playerInSight = true;
 }
 }
 public void OnTriggerExit2D (Collider2D other){
 if(other.gameObject.tag == "Player"){
 playerInSight = false;
 }
 }
 }
Script for enemy shooting player
     using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     
     public class OctorokThrowingRocks : MonoBehaviour
     {
     
     private Rigidbody2D rbody;
     private Animator anim;
     private OctrokFindingPlayer octrokSpottingPlayer;
     
     public Transform throwPosition;
     public GameObject rockThrowObject;
     public GameObject player;
     public float ThrowWaitTime;
     public float ThrowTimer;
     
     // Use this for initialization
     void Start (){
     rbody = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     player = GameObject.FindWithTag ("Player");
     octrokSpottingPlayer = FindObjectOfType<OctrokFindingPlayer>();
     }
     
     void Update()
     {
     // If Player is Sighted
     if (octrokSpottingPlayer.playerInSight)
     {
     GameObject projectile = (GameObject)Instantiate(rockThrowObject);
     projectile.transform.position = throwPosition.position;
     }
     }
     
     }
 
Please help me, Thanks in advance
( octorok is name of my enemy )
Your answer
 
 
             Follow this Question
Related Questions
How to rotate the enemy in 2D top down 0 Answers
Making an enemy go back to its spawn after losing target 0 Answers
How To Destroy/Deactivate one enemy without affecting other enemies of the same type? 0 Answers
My enemy ai won't stay on the ground help please 0 Answers
Problems with enemies 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                