c# - Unity3D spawning 2d objects at fixed locations -


i have object when clicked destroyed , spawns randomly somewhere else on timer. i'm trying make instead of random spots shows @ fixed locations.

i want them randomly spawn @ fixed locations on timed interval, 1 @ time.(so if appears in 1 location lets 5 seconds, destroyed , next 1 appear in different location.)

i attempted fixed spawn locations, void spawner doesn't want work.

i "the object of type "gameobject" has been destroyed still trying access it".

i can fix commenting out on_touchstart destroy line, need it.

here code:

using unityengine; using system.collections;  public class spawner : monobehaviour {      public float appeartime = 0f;     public transform[] teleport;     public gameobject[] prefab;      void spawner(){          int tele_num = random.range(0,5);         int prefab_num = random.range(0,3);         if (prefab !=null){         instantiate(prefab[prefab_num], teleport[tele_num].position, teleport[tele_num].rotation );         }     }       void starttime()     {         startcoroutine(dotime());      }      void onenable(){         easytouch.on_touchstart += on_touchstart;     }      ienumerator dotime()     {         yield return new waitforseconds(appeartime);         spawner();      }      void on_touchstart (gesture gesture){          if (gesture.pickobject != null){             destroy(gesture.pickobject);             starttime();         }     } 

if lead me on right track i'd appreciate it.

thanks.

i figured out. turns out prefabs using incorrect, needed swap them out ones did. ones helped.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -