clonning again and again after sometime
void Update () {
curspwntime -= 1 * Time.deltaTime;
if (curspwntime <= 0) {
instantiatedobj=Instantiate(geek1, new Vector3(-35.86f,6.3f,1.43f), Quaternion.Euler(0,90,0));
curspwntime = spawntime;
}
the problem is after first tme it makes clone of clone .but i only want one clone after every 5 seconds and destroy OnCollisionEnter also doesnot work for clonned objects i had also used corroutines. thanks in advance.
Just to be sure.
Debug.Log(spawntime)
Are you sure that spawntime is 5 and not 0 ?
Could you clarify what you are trying to accomplish? Do you want to spawn only once, after 5 seconds, or do you want to s$$anonymous$$dily spawn every 5 seconds?
Your question is very confusing. What's exactly the problem? Is this code spawning endless copies of the geek1 object without waiting 5 seconds? Please show the code where the variables curspwntime and spawntime are declared - if curspwntime is an int, this code will fail miserably.
Answer by PedroAK · Jun 23, 2017 at 04:19 AM
Try doing that: - Create a method like (void SpawnObject()) - And in the Start() add this InvokeRepeat("SpawnObject", TimeToStartSpawning, RepeatRate) - In your case RepeatRate would be 5
Your answer
Follow this Question
Related Questions
How can you load next the level after you destroy the last clone c# 1 Answer
Instantiate question 0 Answers
Destroy the first instantiated clone after 4 have been instantiated 1 Answer
Passing variables from one script to all clones 1 Answer
Trying to use coroutines in order to use Mathf.Lerp, Lerp instantly jumps values 0 Answers