Комментарии:
Some of my enemies are spawning dead. Do you know what could be going wrong?
ОтветитьBro, how to make a set of enemies coming in a straight line or forming sine wave or in a circle formation like space shooter games.
ОтветитьGreat tutorial sir, thank you so much 🥲🥰
Ответить"Finally im done with the co- annnd its spawning a million every second...." was my exact reaction to the spawner creating a million enemies a second.
Ответить我来考古了,thanks
Ответитьprobably too late, but how can I add max spawn to this?
Ответитьty very much
ОтветитьThanks
ОтветитьIt was so difficult to find a way to spawn enemies. this exmple is simple and clear. Thank you, earned yourself a sub from me
Ответитьusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
public GameObject enemy;
float randX;
Vector2 whereToSpawn;
public float spawnRate = 2f;
float nextSpawn = 0.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Time.time > nextSpawn)
{
nextSpawn = Time.time + spawnRate;
randX = Random.Range(-8.4f, 8.4f);
whereToSpawn = new Vector2(randX, transform.position.y);
Instantiate(enemy, whereToSpawn, Quaternion.identity);
}
}
}
what if i want to spawn the enemy to only one specific location?
ОтветитьThank you so much! i now have a working spawner for my game :D
ОтветитьWhat if you want to spawn only on the y axis?
Ответитьhow do u randomly spawn along the y axis ? so the right and left side of the screen
Ответитьcan someone please help me i need to make the enemies spawn on the y axis aswell because i have a top down game i cant figure it out please!
Ответитьamazing thank you !
ОтветитьThank you for the knowledge ! I hope you have a great day👌
ОтветитьWhat about area spawn in top down game
Ответитьbro can u plzzz for god sake speak a little bit faster because i am an indian and i dont speak English fluently but still at a good pace BTW video was very helpful. :D
Ответитьthx m8
ОтветитьHey i have a problem at the randomspawner im using like in the Video a Vector2 only that i dont want to spawn the enemes at differnt x positions i want them to spawn at random y positions. Than cames the message: Assets\EnemySpawner.cs(28,66): error CS1061: 'Vector3' does not contain a definition for 'X' and no accessible extension method 'X' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?). what is wrong pls dan somebody help me?
some methdes from the Script:
[...]
public GameObject enemy;
float randY;
Vector2 whereToSpawn;
public float spawnRate = 3f;
float nextSpawn = 0.0f;
[...]
if(Time.time > nextSpawn)
{
nextSpawn = Time.time + spawnRate;
randY = Random.Range(-2.5f, 2.5f);
whereToSpawn = new Vector2 (randY, transform.position.X);
Instantiate(enemy, whereToSpawn, Quaternion.identity);
}
[...]
PS: sorry for my bad englisch
How would i make the enemies spawn faster and faster as the game goes on?
ОтветитьScript for people to check if they have typos, (The videos a little blurry) Great Vid!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawnerScript : MonoBehaviour
{
public GameObject enemy;
float randX;
Vector2 whereToSpawn;
public float spawnRate = 2f;
float nextSpawn = 0.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Time.time > nextSpawn)
{
nextSpawn = Time.time + spawnRate;
randX = Random.Range (40.1f, 44.1f);
whereToSpawn = new Vector2 (randX, transform.position.y);
Instantiate(enemy,whereToSpawn , Quaternion.identity);
}
}
}
Hello my friend I was looking around the internet for help for my game and your video was #1 on my recommend thanks again!
Ответитьcan you show to spawn enemies but show the spawner follows the player cause in my game it is an endless runner and the camera follows me so the enemies should spawn following me plz can you help me
Ответитьwhere dis music?????!?!?!?
Ответитьcan we limit the numbers of spawn?
ОтветитьI'm not getting the slots on my script to drag my enemy into. Any idea why?
ОтветитьError :Cannot convert 'UnityEngine.Vector2' to 'UnityEngine.Transform'
Ответитьhow do you get a random y?
ОтветитьThis is great , its simple to understand . Thanks alot.....
ОтветитьThis is super super!! I'm building a 2d top rogue like, and I used this script. It's brilliant! I know there's literally one line of code which will make the enemy not spawn in the player's current transform.position, but I'm not sure how to write it in this code. Would it be an if statement?
ОтветитьPerfect, your are the best.... tks for your help!
ОтветитьThis error keeps on popping up saying "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement." PLS HELP I AM NEW TO UNITY AND NEED TO FINISH THIS GAME!
Ответитьthanks for the tutorial. But I have a problem, because I've incorporated a timer in the script and when i write that if the time is 30 the spawnrate = spawnrate + 2, the enemies don't raise and if i set the spawnrate at 10, the enemies don't spawn anymore. How can i make it raise?
Ответитьthank you my game just got 10000 times harder
And it was hard before too!!
Him : I think it's quite funny to have a clown as an enemy.
Batman : You won't get it.
Really great job thank you!
ОтветитьThat's not a clown, that's Bob Ross
ОтветитьPlease answer can somebody help me it spawns evreywhere and rapid
Ответитьthx
Ответитьcan i use it in a maze type map?
Ответитьdude you are the best
ОтветитьGreat simple video. Thank you Sir!
ОтветитьSimple.clear. on point. Thank you!
Ответитьis there anyway to get the enemys to spawn in front of me all the time never ending?
ОтветитьHoly sh*t m8 this is amazing! I need it to spawn random projectiles on the Y axis so all I had to do was flip a few things around and it works just great!
Edit: After adding a RigidBody2D to my object being spawned, it stopped choosing a random value and didn't spawn according to the position of the spawner.
How do I make it so that the spawn timers don’t get affected in another scene? I have it made so that It starts off with 1 every two seconds then I have 9 more spawners that go off at like 30 seconds and 50 and stuff like that and spawn 1 every 5-20 seconds but when I die and then respawn they all spawn from where it left off
Ответитьthanks!!! :D I learn a lot basic C# from this :D!
ОтветитьHow to do, that in time, spawn speed i increases?
Ответить