HOW TO RANDOMLY SPAWN ENEMY POSITIONS WITH C# UNITY TUTORIAL

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 142

  • @lucafrancis5572
    @lucafrancis5572 10 หลายเดือนก่อน +3

    Amazing. Amazing. Amazing. So simple yet exactly what I needed. Awesome tutorial. Keep doing what you're doing man

  • @nullptryt
    @nullptryt 3 ปีที่แล้ว +2

    This is exactly what I needed thanks bro!! Subscribed!

  • @nyanchangaming8523
    @nyanchangaming8523 4 ปีที่แล้ว +2

    Thank You bro I hope theres more tutorials

  • @latteNmusic
    @latteNmusic 4 ปีที่แล้ว +2

    Thank you for this! It works nicely!

  • @zartl10
    @zartl10 3 ปีที่แล้ว

    Thank you so much for this! Subscribed!

  • @b1ake377
    @b1ake377 3 ปีที่แล้ว +7

    ok so this helped massively and allowed me to progress in my game making, great video btw. how would i go about stopping the models spawning in the same place as it is random so that is a possibility?

  • @rhon5117
    @rhon5117 4 ปีที่แล้ว +12

    How do i make the enemies respawn or how do i recall this code when the enemies die.
    I want the enemies to continuesly respawn every 10s using the method used in this video.

    • @MRFATBEAR
      @MRFATBEAR 4 ปีที่แล้ว

      Do you find the way how to do it yet ? I wanna know too

    • @nicolasazzi9215
      @nicolasazzi9215 4 ปีที่แล้ว

      @@MRFATBEAR ask on unity forums I'm sure you will find an answer

    • @fishman432
      @fishman432 4 ปีที่แล้ว

      You can just make the number of enimes that spawn higher so it lasts longer

    • @johnathonbobe7953
      @johnathonbobe7953 4 ปีที่แล้ว

      have it when an enemy dies it removes one from the enemy counter edit: also have something that triggers the IEnumerator when one dies

    • @sed6673
      @sed6673 3 ปีที่แล้ว

      did u try a do while loop?

  • @arkajyotiadhikary8504
    @arkajyotiadhikary8504 5 ปีที่แล้ว +23

    Sir make a video about ..
    How to make an enemy, Which can react to sound.
    Like if he hears the footsteps than follow the player.
    Thank you.

    • @fecoramirez
      @fecoramirez 5 ปีที่แล้ว +16

      Hope it's not late, but i think it should not be about reacting to the sound. The sound comes from an action, ie: If we wanted the enemy to react to the sprinting sfx, then we should make the enemy check the distance to the player and if the player sprints near a certain range, he should follow you. So it's not about the sound, but the action itself.

    • @fy-b07-causingrenato91
      @fy-b07-causingrenato91 5 ปีที่แล้ว +2

      try making a circle using the gizmo function where you set the range and center it to your character then you would activate the circle by moving your character and make a collision code where if the circle touches the enemy or come close to the radius then the enemy would go react or follow the player

    • @ProdMGD
      @ProdMGD 4 ปีที่แล้ว +2

      @@fecoramirez I'm late but excellent perspective.

    • @slipperysnowball2185
      @slipperysnowball2185 4 ปีที่แล้ว +1

      no im late

    • @ninetieschild9114
      @ninetieschild9114 4 ปีที่แล้ว +1

      im Jordan.

  • @akashraj2488
    @akashraj2488 3 ปีที่แล้ว +1

    Don't know where went wrong.. my while loop is not instantiating enemies. it just puts 1enemy in area instead of 10 each after 0.1f seconds. Below is the code I was using !
    //code for spawning the enemies
    while (enemyCount < 10)
    {
    xPos = Random.Range(180, 216);
    zPos = Random.Range(97, 111);
    Instantiate(theEnemy, new Vector3(xPos, 0.6f, zPos), Quaternion.identity);
    yield return new WaitForSeconds(0.1f);
    enemyCount += 1;
    }

    • @ianpereyra5390
      @ianpereyra5390 3 ปีที่แล้ว

      In the "new Vector3" you are using a number with "f" wich corresponds to time, not to position. That number is the Y axis position so try deleting the "f". This is one month late but I hope you managed to resolve the problem.

  • @vilara8666
    @vilara8666 2 ปีที่แล้ว +4

    I have a bit of a problem. I destroy the enemy game objects when they die, but if the original enemy game object is destroyed, the script won't spawn more enemies because it doesn't find the reference. If I attach the destroying script to the enemies when they spawn, the original one won't disappear tho. Any ideas?

  • @mmazuk1958
    @mmazuk1958 2 ปีที่แล้ว

    Thank you for this tutorial!!!

  • @davidfattore
    @davidfattore 5 ปีที่แล้ว +3

    Hey Jimmy, dude your tutorials are a godsend, please keep them coming. Even though I'm proficient in C#, I'm learning so many new methods and ways of observing and tackling all the little tasks
    I set myself, while I'm creating my Open World Fantasy RPG, which brings me to my request. If at all possible, could you create another mini tutorial involving a money system.
    A while back, I was working through your "How to Make a Game For Free (51 Video) Tutorial" as a sort of baseline and Ep. #7 with the coins got me thinking, would there be a way, if for example each of those coins was a different colour and as your picked them up, they were each calculated as a different denomination. (Red: $5, Green: $10 and so on) and have a overall calculation of the total money accrued as well as calculating the individual denominations.
    Could that be done? In my head as I'm thinking about it seems rather complex, so I'm hoping you can find a way to simply the method.

  • @karlee8608
    @karlee8608 5 ปีที่แล้ว

    You are awesome Jimmy
    Keep it up

  • @BrandonMerrington
    @BrandonMerrington หลายเดือนก่อน

    Thank you kindly sir.

  • @piguy2829
    @piguy2829 4 ปีที่แล้ว +2

    I am new to this and dont understand Coroutine and IEnumerator. Whenever i try to use them i get an error, and when i dont the script starts making clones of clones. Can you help please?

  • @kersh8568
    @kersh8568 5 ปีที่แล้ว +20

    Jimmy, I would love to make an asset for your next tutorial. I am a student in the US getting my degree in AR/VR in a few months and think I could help you expand your tutorials if we worked together.

  • @williamandrade1455
    @williamandrade1455 3 ปีที่แล้ว

    This video helped a lot!

  • @ruben6403
    @ruben6403 3 ปีที่แล้ว +1

    ty helped me sm

  • @leolizard3152
    @leolizard3152 5 ปีที่แล้ว

    Thanks! This will help me out a lot.

  • @esi2047
    @esi2047 4 ปีที่แล้ว +2

    that helped me a lot thank you

  • @Liam-nl5yv
    @Liam-nl5yv 5 ปีที่แล้ว +2

    Cheers mate

  • @LeeTGame
    @LeeTGame 5 ปีที่แล้ว +2

    Thanks. Very clear. :)

  • @philyorke-robinson226
    @philyorke-robinson226 3 ปีที่แล้ว +3

    Hi! Great video, this has helped me so much. Subscribed!! How would I edit the code to have the new enemies face another direction, rotating them by 90 degrees?

    • @david100awesome
      @david100awesome 3 ปีที่แล้ว

      rotate the enemy object its self

    • @dr_f1405
      @dr_f1405 3 ปีที่แล้ว

      Did you find a solution?

  • @andygao4389
    @andygao4389 5 ปีที่แล้ว +2

    How would I do this if I wanted enemies to spawn on a trigger, way walking over a block?

    • @JimmyVegasUnity
      @JimmyVegasUnity  4 ปีที่แล้ว +1

      Put the code inside OnTriggerEnter and attach it to a cube and tick IsTrigger in the collider :)

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      1: make the DropEnemy coroutine public 2: give the block a reference to the GenerateEnemies script 3: Using onTriggerEnter with the block, call your EnemyDrop through your reference like this: reference.StartCoroutine(EnemyDrop());

  • @DidoeS
    @DidoeS 3 ปีที่แล้ว +1

    For some reason even without the While loop for me is spawning endlessly... any ideas how I can fix it ?

    • @ecayeta
      @ecayeta 3 ปีที่แล้ว +1

      You need the while loop so it's not spawning endlessly

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      Like ecayeta said. The while condition is the only thing preventing it from spawning enemies endlessly. Without the condition saying "so long as there are less than 10 enemies, spawn an enemy," the corountine would just spawn an enemy every 0.1 second.

  • @hellofun6496
    @hellofun6496 5 ปีที่แล้ว +1

    I love you .. please keep going

  • @zubbag
    @zubbag 4 ปีที่แล้ว +1

    hi great vid
    is it possible to duplicate the spawn object?
    also the enemy spawns in the same location when i press play is there anyway of fixing it?
    many thank
    keep up the great content

  • @PIGQuiky
    @PIGQuiky 6 หลายเดือนก่อน

    not sure ill ever get a response to this but ive tried so much googling already... any chance you could show a way to exclude coordinates inside that range? like say you didnt want them spawning in a 5x5 area. i cannot find an answer on how to do this for the life of me

    • @JimmyVegasUnity
      @JimmyVegasUnity  6 หลายเดือนก่อน +2

      what you could try and do is add some logic gates like.. if x > 2 && x < 3 then you’d restart the method
      so basically it will check to see if the x position is between 2 and 3.. so that would be like an exclusion zone. naturally do the same with the Z too

  • @takuya2431
    @takuya2431 4 ปีที่แล้ว +1

    Hey, Is there any way that i can multiply the " Instantiate(enemy, new Vector3(xPos, 2, zPos), Quaternion.identity); " code by the number of waves?
    I cant really figure it out.
    I managed to make the enemies disappear on colission with my gun and the code repeats itself once the "enemycount == 0".
    The wave also increased by 1 when "enemycount" reaches "0"
    Thanks in Advance

    • @PanikGrafik
      @PanikGrafik 4 ปีที่แล้ว

      What do you want to do? Add 1 enemy on wave1, 2 on wave2 etc? If so, have an int that stores which wave you are on and run the instance that number of times, or append the while-parameter.

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      Make the 10 in the while condition a variable so that you can change it depending on the wave, and then once all enemies have been defeated, call it again. Optimally, you would check if all enemies have been defeated in the same script that kills the enemies.

  • @funja
    @funja ปีที่แล้ว

    Awesome thank you Jimmy , How do i make them follow the player as soon as they appear ?

    • @PoopEaterr_27
      @PoopEaterr_27 ปีที่แล้ว

      Funja are you still interested in coding this? I may have an answer for you!

  • @littlermganimations2568
    @littlermganimations2568 3 ปีที่แล้ว

    This helped but for some reason they are spawning on a grid is there any way to fix this

  • @trixter380xzgaming
    @trixter380xzgaming 4 ปีที่แล้ว

    How do you limit the amount of enemies spawned as well as how to delete them after they leave the screen

  • @JackaldudeVR
    @JackaldudeVR 3 ปีที่แล้ว

    I’m having an issue. using your example if I were to kill one of the 10 enemies spawned in the enemy count isn’t going down and therefore aren’t spawning new enemies. What do you think I’m doing wrong?

    • @JimmyVegasUnity
      @JimmyVegasUnity  3 ปีที่แล้ว

      Good question. Place the original enemy below the map on a random cube.

  • @hyuhragnarook
    @hyuhragnarook 5 ปีที่แล้ว

    what building pack is that?

  • @MrPablosek
    @MrPablosek 3 ปีที่แล้ว

    Can I somehow make the enemies spawn at a local position? My rooms are randomly generated.

  • @josho1994
    @josho1994 4 ปีที่แล้ว

    It says this- error: Assets\scripts\EnemySpawnerScript.cs(12,17):errorCS1002; expected

    • @hotdogg2134
      @hotdogg2134 4 ปีที่แล้ว

      you probbably forgot the ; at the end of a command if not this is not enough information to just tell you what the problem is

  • @ZiRR0
    @ZiRR0 4 ปีที่แล้ว

    Thank you!!!

  • @slipperysnowball2185
    @slipperysnowball2185 4 ปีที่แล้ว +1

    when I do it it says cant convert double to float

    • @dragomirpetrov5600
      @dragomirpetrov5600 4 ปีที่แล้ว

      You need to put an "f" at the end of the value to register it as a float

  • @wrayth3951
    @wrayth3951 ปีที่แล้ว

    If you wanted a random number of enemies, could you also enemy count random range?
    Also, what if you're attempting to put in more than one enemy type? Would a separate script for each be best, or perhaps just additional ones in the original script?

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน +1

      Yep.
      Create an array containing all of the different enemies' prefabs* (called, say...potentialEnemies), and then in the Instantiate of DropEnemy, use potentialEnemies[Random.Range(0, potentialEnemies.Length)]
      * to do this, say "public GameObject[] potentialEnemies;" and then in unity editor drag in all of your prefabs into the array.

  • @DavidAdochiti
    @DavidAdochiti 3 ปีที่แล้ว

    what if i want to keep spawning enemies? for example i spawn 10 enemies, wait 5 seconds, spawn another 10, etc?

    • @kieranrutherford4818
      @kieranrutherford4818 3 ปีที่แล้ว

      Hi, i know how to do this. Do you still need to know how to do it?

    • @DavidAdochiti
      @DavidAdochiti 3 ปีที่แล้ว

      @@kieranrutherford4818 yes please

  • @Debugg
    @Debugg 4 ปีที่แล้ว +1

    Hey how can i increase the amount of enemy by time . :D

    • @Andrelas11
      @Andrelas11 4 ปีที่แล้ว

      Think about what type of data you will be working with. This always helps me work my way through what I might need to do. You want to the number of so you can create two variables that hold those value.
      private int maxEnemies = 10;
      private int enemyIncrease = 5;
      You want to increase this number . Thankfully Unity already has methods available to let you operate with time such as: Time.deltaTime
      Now you can set up a separate method that will track the time and then increment the maxEnemies(10) by your enemyIncrease amount (5) to give you a new maxEnemies variable of (15). You will have to figure out exactly how long you want to wait between each increase.
      Make sure to use "+=" so that Unity overrides the maxEnemies variable each time the method is called. Otherwise it will default back to the value we set above (10) and then add the enemyIncrease (5) and the number will always be 15. Using "+=" will override the previous maxEnemies variable and reset it to the new value each time.

  • @Infernoz5
    @Infernoz5 3 ปีที่แล้ว

    Im having problems with changing the rotation of the enemy could you help

    • @JimmyVegasUnity
      @JimmyVegasUnity  3 ปีที่แล้ว

      That's to do with AI, not spawning. I don't even know your AI set up, so I'm unable to help without knowing. I have plenty of tutorials on AI though

  • @BlondiFoks
    @BlondiFoks 4 ปีที่แล้ว

    Hey, when I destroy real enemy in the game, the code crashs. However when I destroy clone enemy, no problem. Please help me.

    • @hitman7860
      @hitman7860 4 ปีที่แล้ว +13

      make the enemy prefab and then remove the real enemy use only the prefabs

  • @buggus5702
    @buggus5702 8 หลายเดือนก่อน

    May the God bless you And my Final project too.

  • @erlanggachakra1074
    @erlanggachakra1074 5 ปีที่แล้ว

    how do i attach a script on the instantiated clone object? if it hasnt spawn yet?

  • @dragomirpetrov5600
    @dragomirpetrov5600 4 ปีที่แล้ว

    The IEnumerator shows an error if I place it outside the Start function.

    • @JimmyVegasUnity
      @JimmyVegasUnity  4 ปีที่แล้ว

      you’ve done it wrong then. a coroutine cannot exist inside a method

    • @dragomirpetrov5600
      @dragomirpetrov5600 4 ปีที่แล้ว

      @@JimmyVegasUnity I guess I did something wrong because now everything is OK with the code. Unity is taking 5mins to load so I can't test it fully. Thank you for the tutorial though. It helps immensly. Is there any difference in the code if we're using Unity 2020?

    • @JimmyVegasUnity
      @JimmyVegasUnity  4 ปีที่แล้ว +1

      code is usually the same in any version. there may be minor changes in some libraries, but code we wrote, say 5 years ago, will still work now 👍

  • @Samurai-fx8cu
    @Samurai-fx8cu 3 ปีที่แล้ว

    Thanks bro huge help but my game crashed like 100 enemies spawned lol

  • @ankitkc9213
    @ankitkc9213 4 ปีที่แล้ว

    public variables are not showning in inspector please help..

    • @JimmyVegasUnity
      @JimmyVegasUnity  4 ปีที่แล้ว

      Is there an error in the script?

    • @ankitkc9213
      @ankitkc9213 4 ปีที่แล้ว

      @@JimmyVegasUnity no

  • @blockthechainer
    @blockthechainer 5 ปีที่แล้ว

    How you can spam the enemies slowly, like appear 3 secs later the last spam

    • @JimmyVegasUnity
      @JimmyVegasUnity  5 ปีที่แล้ว +1

      On the line with WaitForSeconds, change the value to 3

    • @blockthechainer
      @blockthechainer 5 ปีที่แล้ว

      OMG i fool myself @@JimmyVegasUnity i didnt watch that lane OK ty btw hehehehe feel like a total blind noob right now ty tyt master

  • @mehmetkans1302
    @mehmetkans1302 5 ปีที่แล้ว

    Hey, Jimmy. Great videos. I was wondering if you could change the value of spawning enemies while in game like a Call of duty zombie round system. Each round it spawns more zombies. Do you have any suggestions for that? I could make dozens of Ienumerators for each round but that wouldn't be really praticial, would it?

    • @sherrodfinley6745
      @sherrodfinley6745 4 ปีที่แล้ว

      Did u come up with a solution

    • @panickal
      @panickal 2 ปีที่แล้ว

      You could raise the amount to the power of 1.2 or something like that.

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      Yep so whenever a new round starts, change the 10 in the while loop and recall the coroutine (make the 10 in the while loop a variable)

  • @Adkinsy85
    @Adkinsy85 5 ปีที่แล้ว

    Do you know how to respawn same enemy when player kills him ?

    • @legendaryitem2815
      @legendaryitem2815 5 ปีที่แล้ว +1

      Look into object pooling. You can then have a set number of instances of enemies which you can reuse.

    • @Adkinsy85
      @Adkinsy85 5 ปีที่แล้ว

      @@legendaryitem2815 object pooling ok thank you brother 😁
      Also can you tell how toadd a grab attack like if player grabs enemy Then he can chokslam him in a 3d game ?

    • @thomasglassbrook7778
      @thomasglassbrook7778 5 ปีที่แล้ว

      ​@@Adkinsy85 Another way to do that would be .. (youll need to add on the rest of his code but this will let the,m dissappear and reappear when their health reaches 0 )
      public int EnemyMaxHealth;
      public int EnemyCurrentHealth;
      // Start is called before the first frame update
      void Start()
      {
      EnemyCurrentHealth = EnemyMaxHealth;
      }
      public int respawnTimer = 5;
      public void DamageEnemy(int damage)
      {
      EnemyCurrentHealth -= damage;
      if (EnemyCurrentHealth < 1)
      {
      //Destroy(gameObject);
      this.GetComponent().enabled = false;
      this.GetComponent().enabled = false;
      Invoke("Respawn", respawnTimer);
      }
      }
      void Respawn()
      {
      //FindObjectOfType();
      this.GetComponent().enabled = true;
      this.GetComponent().enabled = true;
      }
      }

  • @Andyyyyyy8
    @Andyyyyyy8 5 ปีที่แล้ว

    Hello! Great Video!
    How can I set the minimum distance between spawned objects?
    Thank you!

    • @Andyyyyyy8
      @Andyyyyyy8 5 ปีที่แล้ว

      I should say that the Collider can't be used, since I have a trigger on it.
      How should I do it?

    • @Andyyyyyy8
      @Andyyyyyy8 5 ปีที่แล้ว

      @kyan ryan ok. Thank you :)

  • @closed9009
    @closed9009 5 ปีที่แล้ว +3

    Your explanation is very good, very useful and easy
    But if you can explain to us how to make a multi-player game
    Thank you

  • @hungamesdev
    @hungamesdev 5 ปีที่แล้ว

    How to do not spawn on each other the enemys?

    • @JimmyVegasUnity
      @JimmyVegasUnity  5 ปีที่แล้ว

      Colliders and rigidbody

    • @hungamesdev
      @hungamesdev 5 ปีที่แล้ว

      @@JimmyVegasUnity Not works for me. If a set the rigidbody to kinematic, nothing change, enemy spawn on each other. and if i set to not kinematic and the enemy spawn on each other the enemy fly away.

  • @rickmasterKKK
    @rickmasterKKK 3 ปีที่แล้ว

    How can i respawn them?

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      If you want more enemies to spawn (like a round system that gets progressively harder) make the 10 in the while loop a variable and increase it every round. Then, call the coroutine again.

  • @Volltagge
    @Volltagge 4 ปีที่แล้ว

    unity crashes when i use"while"

    • @Andrelas11
      @Andrelas11 4 ปีที่แล้ว +1

      Sounds like your stuck in an infinite loop. Once the code hits a while statement it will run that portion of the code until there is something that tells it to stop which is what you are putting in the parenthesis after the "while". My guess is your enemy count is never reaching your set max enemy parameter in the method either because a variable isn't set right or your not incrementing by 1.
      Anytime I do a while loop while I am developing I like to code in a safeguard that stops the loop in case I forgot to set up a condition properly. Otherwise its very hard to get Unity to respond once its stuck. You can either implement that into your game to prevent crashes just in case or remove it once your loop is working appropriately.

  • @sergeys7771
    @sergeys7771 3 ปีที่แล้ว

    nice, teach beginners use anti patterns such as magic numbers. Very good

  • @brunofontelo1262
    @brunofontelo1262 5 ปีที่แล้ว

    how to make the enemies spawn forever pls?

    • @JimmyVegasUnity
      @JimmyVegasUnity  5 ปีที่แล้ว

      That is not advised. Why would you want enemies spawning forever? that will inevitably freeze the game up because you're creating an infinite loop.

    • @brunofontelo1262
      @brunofontelo1262 5 ปีที่แล้ว

      @@JimmyVegasUnity i need that in my game
      Its a project for school

    • @brunofontelo1262
      @brunofontelo1262 5 ปีที่แล้ว

      @@JimmyVegasUnity can u pls tell me how to do that

    • @JimmyVegasUnity
      @JimmyVegasUnity  5 ปีที่แล้ว

      I am telling you now, no. That is NOT something you should be doing. Like I said, infinite loops will break your game.

    • @brunofontelo1262
      @brunofontelo1262 5 ปีที่แล้ว

      @@JimmyVegasUnity ok thanks, but can i make a if that calls your spawn generetor?

  • @mlgpro60
    @mlgpro60 5 ปีที่แล้ว

    Could you explain your code more or summarize what important parts do
    BTW I like the vid 😄👍

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      I think he explained it pretty nicely; what do you need help with?

  • @jakelisacki7656
    @jakelisacki7656 3 ปีที่แล้ว

    IDK how it happened but your code broke my game hahaha.

    • @jakelisacki7656
      @jakelisacki7656 3 ปีที่แล้ว

      I figured it out. I attached the Script to my enemy instead of empty object. I DO NOT RECOMEND hahahaha

  • @ok_doge608
    @ok_doge608 5 ปีที่แล้ว

    make door system tutorial

  • @trymeielsen5299
    @trymeielsen5299 5 ปีที่แล้ว

    How to you make them spawn forever

    • @brunofontelo1262
      @brunofontelo1262 5 ปีที่แล้ว

      did u find a way to do that?

    • @dronecon5006
      @dronecon5006 5 ปีที่แล้ว +1

      Spawn Forever
      private float xPos;
      private float yPos;
      private float zPos;
      public float spawnNext = .1f; //Time until next spawn!
      public bool startRightNow = false; //Enable to spawn an enemy at the start.
      public GameObject theEnemy; //put an Enemy into this slot.
      private void Start()
      {
      if (startRightNow)
      {
      EnemyDrop();
      }
      }
      private void Update()
      {
      Invoke("EnemyDrop", spawnNext);
      }
      private void EnemyDrop()
      {
      xPos = Random.Range(0, 50);
      yPos = Random.Range(40,41);
      zPos = Random.Range(0, 30);
      Instantiate(theEnemy, new Vector3(xPos, yPos, zPos), Quaternion.identity);
      }
      The key here is Invoke(). If you're only setting this once, and you don't need the ability to change the timer from emitter to emitter, you could also write:
      Invoke("EnemyDrop", 1f);
      This would create an enemy every second until the program was stopped.
      Invoke("EnemyDrop", 0.1f);
      0.1f Will Invoke the EnemyDrop() Method 10 Times Per Second!
      If you're killing the Enemies, you may want to look into Object Pooling. If you're just spawning crap to see how long your computer will last before it crashes, this will do it!

  • @DavidAdochiti
    @DavidAdochiti 3 ปีที่แล้ว

    i made 999 into 1k! :DD im proud of myself :D

  • @OfficialMrHyena
    @OfficialMrHyena 5 ปีที่แล้ว

    wolfenstin 3D ep 12

  • @levaneva8178
    @levaneva8178 2 ปีที่แล้ว

    Error :\

  • @irtizamazidrhythm9736
    @irtizamazidrhythm9736 5 ปีที่แล้ว

    Oh .. oops second one

    • @peterriley9913
      @peterriley9913 5 ปีที่แล้ว

      So this is literally the third

  • @irtizamazidrhythm9736
    @irtizamazidrhythm9736 5 ปีที่แล้ว

    First one

  • @Daviejones00
    @Daviejones00 3 ปีที่แล้ว

    How do you make it to where they only spawn when a player come into a certain distance of them?

    • @trevorclifton7361
      @trevorclifton7361 4 หลายเดือนก่อน

      Assuming you have an empty centered in the middle of the room like this guy did, you could just call the DropEnemy coroutine when the player is a certain distance from the empty. First, get a reference to the player's transform, then use Vector3.Distance(transform.position, playerTransform.position)