[C#] Only one instantiate object is working, the rest is not.. Help meee
How to say this... I have succesfully spawning an object with the Instantiate But I want the object to spawn every 3 second, so I add script to check every 3 second, spawn one
The spawned instantiate, in this case "spider", when he sees my player, he will run away - The first spawned instantiate is working perfectly like it should (give me message my player is near, and then walks away) - The second, third, and so on able to give me message that my player is near, but it won't move..
Here's My code
public class EnemySmallNest : MonoBehaviour {
public GameObject enemySpider;
private GameObject enemySmall;
float startTime = 0;
private Vector3 currentNestPost;
// Use this for initialization
void Start () {
currentNestPost = new Vector3 (transform.position.x, transform.position.y, transform.position.z);
}
// Update is called once per frame
void Update () {
startTime += Time.deltaTime;
if (startTime >= 3) {
enemySmall = Instantiate (enemySpider, currentNestPost, Quaternion.identity) as GameObject; //Spawn Spider
startTime = 0;
}
}
}
anyone can help me fix this?
add script of the spider then we can see whats wrong with that.There is no problem with this one.
Your answer
![](https://koobas.hobune.stream/wayback/20220612063539im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
uNet Spawning Objects 0 Answers
How to know if there is no possible space on board to spawn. 1 Answer
Spawn Prefab based on int value 1 Answer
how can I add a maximum of enemies to be generated for each wave? 0 Answers
How do I spawn a certain amount of enemy ai / It's spawning too many enemy ai's in my scene 0 Answers