i need some help, can you help me... i copy the code but i dont know how change rocks movement from below to up.... i try the code but when i play the scene the rocks its not found but it is work....
The code is not workkng for me and i dont know why it says i have have no where to put the asteroid prefab or the respawn time it wont pop up kn the knspector
I see you haven't uploaded in a while. I wanted to let you know that all your videos have been very helpful to me and that I would like to see more content from you, if you can of course. Thanks for your service.
Thanks bud! Don't worry I will be posting videos again soon. I needed to take some time off to build out a website and do some rebranding, and things like that. Hopefully by the end of this month I'll have a consistent posting schedule. Cheers!
Hi, I just found this channel and it's very clear to follow along, but also I've been watching alot of vids these days because of the steep learning curve... It starts to make a little more sence now...
Thornlock thank you for the support. I’ll be taking off the month of December to work on another project but after that I’ll be posting at least once a week.
i'm very new to unity, c#, making games and stuff. i don't have a deep understanding of most of this, but i noticed that the code you used here 4:29 "if(transform.position.x < screenBounds.x)", the < screenBounds.x part only seems to work when the camera projection is set to perspective. i've been using the orthographic camera projection because i was told that it's better for 2d games. if not would you mind explaining the difference? also do you plan on making a tutorial like this for an orthographic camera projection?
The simple answer is perspective camera inverts the screenBounds value. So if you’re dealing with orthographic either multiply it by -1 or flip the if statements. Hope that helps
@@pressstart6864 thanks a lot for the information. i was able to get it to work with orthographic projection when i multiplied it by -1. i wasn't able to figure out how to get it to work by flipping the if statements though.
At 9:01 you said we could use a boolean that changes to true when the game is ready to start. How do I know when the game is ready to start? Because my game has a title and doesn't start right away, so i dont want the enemies to spawn before the game actually begins, but how can I do this?
So I believe as TaniCorn is pointing out, it should be pronounced co-routine, not Quarantine, although that's all been on our mind recently. EDIT Thanks for the great vid!
I followed your tutorial step by step. My script is identical to yours (have checked for 1h). But nothing seems to spawn. If I put an asteroid manually in, it does, what it should. but if I remove it and try using the prefab, it just doesn't spawn anything... pls help! (using the 2019 Version of unity)
When the camera projection is "perspective" the objects despawn normally, but when I set it to "orthographic" the objects spawn faster than they can despawn. Can anyone help, plaease?
hey mate, I'm having issues I've copied and pasted the same code for destroying the asteroids but they are being destroyed at runtime, any suggestions? Please respond me fast, I have an assignment to finish
Hey this is great thanks! my question is I wanted to add a different object to be spawned so I made a new coroutine, but for some reason that one never spawns its object. Is the first coroutine interfering?
i'm getting an error saying object referance is not set tto an instance of an object for this line of the code and its saying it for both scripts screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z)); any one have any suggestions on how to fix this?
I have a small question, I'm shooting bullets, although it seems I'm creating multiple bullet game objects and I only want to fire one of them when the space key is pressed, how do we limit the rate of a prefab?
Hi , I appreciate the video. Just a quick question : so I'm working on a simple 2D side scrolling runner, the idea is to deliver Pizza to randomly generated houses : green red and blue ( to add a bit of challenge ) , will the script you provided in this video work ? I've been trying for so long but I can't make the houses spawn after the player collides with them. Any help would be appreciated. Thanks.
Hey! There is a bug .... My Obstacles dont despawn and are spawning only there where the camera startet but when the camera is in another position the Obstacles are still spawning there where the camera was at the beginning... Can anyone help?
Hey! great tutorial! Is there a way to increase the rate at which the astroids spawn over time? I would like them to spawn more frequently as the game progresses.
i really like your tutorial. But i want to make a game that needs to spawn obstacles from above and when i tried changing the code i couldn't figure out how to make the spawn above (on the x axis) please help me out.
If i were to do this for a top down shooter i should just replace the values with Z instead correct ? im trying to do this for a top down space shooter
Yes just reverse the code to work for the Y axis: a.transform.position = new Vector2(Random.Range(-screenBounds.x, screenBounds.x), screenBounds.y * 2); Then modify the velocity also, or just add gravity.
Hi , I tried it for Y axis, but the "DEPLOYASTEROID.CS" did not work for me. I tried changing the x axis to y axis, but the spawning didn't work. Pls help me. Thank you.
I used a particle effect. For start size choose a value less than 0.1 and then under Renderer > Material choose "Sprites - Default". Then just rotate it 90 degrees.
Did you create a folder in assets called prefabs and added the rock in there? Then assign the rock from the prefab folder to the script that deploys the rocks, located in the main camera.
Maybe you won't answer but I still want to ask. You wrote the respawn time as "WaitForSeconds(RespawnTime), but I want it to create a new object for each disappearing object condition, not time. So the respawn condition is for another object to disappear. How can I do this? Thanks in advance for the information you will provide. I wish you good work.
My object will not delete when off the screen not sure why maybe there is a problem with the camera bounds , any suggestions? (I had to change the code to what you put in the comments, to make my prefab appear on the screen as it wasn't showing with your original code)
Hey, can someone help me with a problem I am running into? So I am trying to make this script but instead of the asteroids going sideways I want them to go down so I did that but now the asteroids are going down on one line. In the "deployAsteroids" script I have tried to change "screenBounds.x * -2" to "screenBounds.y * -2" I have also tried to change the Random.Range screenBounds to x instead of y. Btw I am a beginner coder so I am sorry if it is something obvious.
I’m am working on a project for college and this really helped me out, however I’ve been trying to connect it alongside a network manager and I can’t get the second asteroid script to work like they just don’t spawn in. Any tips?
@@pressstart6864 It appears static, but it turns out it's technically moving? I tried the code you suggested to someone having a similar issue and it resolved my problem :)
How would you try giving the spawning transforms of the 2nd spawning object a bit of a minimum distance from the spawn transforms before? What I mean more precise: I want to spawn several objects in a scene but they won't move nor disappear after they spawned. They should spawn in a pre-set area with a pre-set number of objects that spawn, but they should all have a minimum distance around them, so that the meshes won't overlap. I'm still rather new to coding so I'm not always quite sure what can and can't be done, would appreciate the help ':D
In asteroid.cs, change this line to move from top to bottom: rb.velocity = new Vector2(0, -speed); and in deployasteroid.cs change this line to have it appear above the camera: a.transform.position = new Vector2(Random.Range(-screenBounds.x, screenBounds.x), screenBounds.y * -2);
Copy & paste source code: pressstart.vip/tutorials/2018/09/25/58/spawning-obstacles.html
i need some help, can you help me... i copy the code but i dont know how change rocks movement from below to up.... i try the code but when i play the scene the rocks its not found but it is work....
i dont know where is my fault
that code used in perspective camera...not orthographic
The code is not workkng for me and i dont know why it says i have have no where to put the asteroid prefab or the respawn time it wont pop up kn the knspector
@@myworld7667 did you change the axes
"Quarantines can look scary but they're actually quite simple"
The World:"Sorry what I don't understand?"
TaniCorn I think you mean coroutines
Look where we are now and you might understand lol
@@soaringsquid0.129 r/woosh
YES THIS, i was like.... is it supposed to be Quarantine... or Co - ROUTINE?!?!?!
IKR
1 of the only youtubers that actually explain in a way that even beginners can understand.
I see you haven't uploaded in a while. I wanted to let you know that all your videos have been very helpful to me and that I would like to see more content from you, if you can of course. Thanks for your service.
Thanks bud! Don't worry I will be posting videos again soon. I needed to take some time off to build out a website and do some rebranding, and things like that. Hopefully by the end of this month I'll have a consistent posting schedule. Cheers!
Hi, I just found this channel and it's very clear to follow along, but also I've been watching alot of vids these days because of the steep learning curve... It starts to make a little more sence now...
9:35 OK FINALLY I was so confused because nowhere could I find where you actually reference the prefab itself god bless you
I dont have it and i already save the script, someone help?
I was searching for a solution for months and you explained it very finely.
I liked and subscribed. :)
Thank you. :)
This is pretty neat and so simple. Very well explained! Excellent job!
Thanks dude
Great tutorials dude! Really hope you keep making these
Thornlock thank you for the support. I’ll be taking off the month of December to work on another project but after that I’ll be posting at least once a week.
Bro, you're AWESOME. The only one in the whole World Whide Web who helped me out with exactly what I needed. Muchas gracias
i'm very new to unity, c#, making games and stuff. i don't have a deep understanding of most of this, but i noticed that the code you used here 4:29 "if(transform.position.x < screenBounds.x)", the < screenBounds.x part only seems to work when the camera projection is set to perspective.
i've been using the orthographic camera projection because i was told that it's better for 2d games. if not would you mind explaining the difference? also do you plan on making a tutorial like this for an orthographic camera projection?
The simple answer is perspective camera inverts the screenBounds value. So if you’re dealing with orthographic either multiply it by -1 or flip the if statements. Hope that helps
@@pressstart6864
thanks a lot for the information. i was able to get it to work with orthographic projection when i multiplied it by -1. i wasn't able to figure out how to get it to work by flipping the if statements though.
my object disappears on play. help
from the amount of LIKES it seems a lot of us have the same issue my self included. they flash quickly at the left side of the screen...
Maybe because of camera. Go to camera and change projection to Perscpective
@@primebalpreet5214 kiitos! (Thanks in finnish)
@@primebalpreet5214 thanks that works
@@primebalpreet5214 thx 🙏🏻
Thx. This is mega helpful. I have been looking for this for a long time, now i found it!
Hey man just wanted to say this was such a great help for me. You are awesome, keep it up!!
Hey can anyone help me!
My Game Object (Asteroid) is spawning way behind the camera view and gets destroyed.
Thanks man, just what I needed, will definitely use this knowledge for my project! :)
This really helped me for my mini platform game assignment. Thank you!
Simply amazing. It's hard to find such a good quality tutorials like yours. Thanks a lot :)
He does not even damn!! Explains it Whats the thanks for
dude you give me a jumpscare with that intro
Idk if your still respone but i have an question how to let the astriod fly down unstat of to the left
Change the velocity to be on the Y axis
@@pressstart6864 I am beginner of coding and my question is what I have to do to change the velocity to y axis. Hope you respone quickly
At 9:01 you said we could use a boolean that changes to true when the game is ready to start. How do I know when the game is ready to start? Because my game has a title and doesn't start right away, so i dont want the enemies to spawn before the game actually begins, but how can I do this?
So I believe as TaniCorn is pointing out, it should be pronounced co-routine, not Quarantine, although that's all been on our mind recently.
EDIT
Thanks for the great vid!
What is the best resolution to an image to get it to
I followed your tutorial step by step. My script is identical to yours (have checked for 1h). But nothing seems to spawn. If I put an asteroid manually in, it does, what it should. but if I remove it and try using the prefab, it just doesn't spawn anything... pls help! (using the 2019 Version of unity)
yeh this is Bull! same thing happened to me no spawn
When the camera projection is "perspective" the objects despawn normally, but when I set it to "orthographic" the objects spawn faster than they can despawn. Can anyone help, plaease?
hey mate, I'm having issues I've copied and pasted the same code for destroying the asteroids but they are being destroyed at runtime, any suggestions? Please respond me fast, I have an assignment to finish
This actually worked for me! Thank you so much!!
it fixed my problem that i was having with my spawn system thanks a lot😎😎😎😎😁😁😁😁😁😁😁😁
I will leave this comment just for stats. i would love for your channel to get big
Thank you for the support :)
Can you tell me that how to use two prefabs to spawn.
Is there a way to cycle through several asteroid prefabs in the spawn?
Super video!! Only thing is that you've could use the asteroid width instead of the (* 2/-2), but for the rest great job !!
thanks!!!
Hey this is great thanks! my question is I wanted to add a different object to be spawned so I made a new coroutine, but for some reason that one never spawns its object. Is the first coroutine interfering?
i'm getting an error saying object referance is not set tto an instance of an object for this line of the code and its saying it for both scripts
screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
any one have any suggestions on how to fix this?
You need to set your main camera. Basically it's just a tag in the inspector. Set it to main and the code will work
I was wondering how you would make the Asteroids spawn downwards vertically, instead of horizontally. Thanks.
@KeepenCool Thanks! I managed to get it working!
@@milo1269 pls can u explain it to me how
I have a small question, I'm shooting bullets, although it seems I'm creating multiple bullet game objects and I only want to fire one of them when the space key is pressed, how do we limit the rate of a prefab?
It is great but what is corontine it says it doesn’t exist plz help when I delete it they don’t spawn 😢😢😢
Hi , I appreciate the video. Just a quick question : so I'm working on a simple 2D side scrolling runner, the idea is to deliver Pizza to randomly generated houses : green red and blue ( to add a bit of challenge ) , will the script you provided in this video work ? I've been trying for so long but I can't make the houses spawn after the player collides with them.
Any help would be appreciated. Thanks.
This helped so much in my game. Thank you
How do I spawn it in just a staight line?
Thanq for the clear explanation.. It helped a lot :)
hello from french,
thank you for tuto, you help me ^^
a good day.
Nice tutorial, very clear!
Thank you!
when i use the Removing objects from the scene once they leave the screen script its just destroys the objects even if its seen by the camera
Hey! There is a bug .... My Obstacles dont despawn and are spawning only there where the camera startet but when the camera is in another position the Obstacles are still spawning there where the camera was at the beginning... Can anyone help?
i need help because when my mane object is destroyed the clones are not spawning any more
can someone tell me whats wrong
My enemies are just spawning off to the side not even in game view :/ Any help?
mines to any help
same
Hey! great tutorial! Is there a way to increase the rate at which the astroids spawn over time? I would like them to spawn more frequently as the game progresses.
i have the exact same question
Decrease the respawn time variable value
thankyou very much but how i make the rocks move from below to up?????
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.
Brilliant tutorial, thank you.
The asteroids doesnt start at the right side. It starts in the middle. Does anyone know what to do?
Is there anyone who did the same but in 3D? I tried but that didn't went well
Cool tutorial ,thanks 👍
i really like your tutorial. But i want to make a game that needs to spawn obstacles from above and when i tried changing the code i couldn't figure out how to make the spawn above (on the x axis) please help me out.
Clean explanation.. Great work
thank you so much!
If i were to do this for a top down shooter i should just replace the values with Z instead correct ? im trying to do this for a top down space shooter
It's relative to your camera. You could just rotate your camera or yes change certain values. Not every project is going to be the same.
does somebody knows how to the same thing but the asteriods goes down not sideways
Also is there anyway to code it so instead, it seems like the enemies are 'dropping' from the top of the screen to the bottom?
Yes just reverse the code to work for the Y axis:
a.transform.position = new Vector2(Random.Range(-screenBounds.x, screenBounds.x), screenBounds.y * 2);
Then modify the velocity also, or just add gravity.
@@pressstart6864 Amazing; thank you so much! Currently working on a game for my university assignment, and your tutorials are a HUGE help!
hey, i have problem, when my first prefab gets destroyed, unity stops cloning it since it's destroyed
any solution for this?
Dont have your prefab in your scene just add it to the camera
How can I make more obstacles spawn through the progress of the game? Also great tutorial.
Thank you very much it helped a lot in my project
Hi , I tried it for Y axis, but the "DEPLOYASTEROID.CS" did not work for me. I tried changing the x axis to y axis, but the spawning didn't work. Pls help me. Thank you.
Just a great tutorial as always ! thanks
Can you explain us how to create the space background ?
I used a particle effect. For start size choose a value less than 0.1 and then under Renderer > Material choose "Sprites - Default". Then just rotate it 90 degrees.
@@pressstart6864 Great ! It looks so awesome !
Thanks for helping me! I learned a lot!
For some reason, whenever I run my game, the asteroid disappears right way. Anyway I can fix this issue?
Idk if you still need this but change the camera to perspective (I had the same problem, this just doesn't work with orthographic that's all)
@@lordcatington8188 had same problem as his, thanks m8
@@lordcatington8188 Thank you so much you really helped me
@@lordcatington8188 Thank you very much!!
ORTHOGRAPHIC CAMERAS objects do not come out.
How can we find a solution?
Objects are outside the screen.
How can we put the screen inside. ?
I made a game with Camera moves with Player please how script must looks to be good?
Rocks stop spawning after one of them being deleted, how can I keep them spawning?
You're probably deleting the object that spawns the obstacles. Try deleting the obstacles individually instead.
@@pressstart6864 I found where the problem was, I forgot to delete the prefab in the scene before launching the game LOL
Did you create a folder in assets called prefabs and added the rock in there? Then assign the rock from the prefab folder to the script that deploys the rocks, located in the main camera.
How did you solve the problem?
@@Changelllelle wow thank you that was it :)
Maybe you won't answer but I still want to ask. You wrote the respawn time as "WaitForSeconds(RespawnTime), but I want it to create a new object for each disappearing object condition, not time. So the respawn condition is for another object to disappear. How can I do this? Thanks in advance for the information you will provide. I wish you good work.
Hello how to instantiate prefab to the main camera position?
Whats the difference between coroutine and invoke?
Where were you sir awesome video 😁 thanks
My object will not delete when off the screen not sure why maybe there is a problem with the camera bounds , any suggestions? (I had to change the code to what you put in the comments, to make my prefab appear on the screen as it wasn't showing with your original code)
Hey, can someone help me with a problem I am running into? So I am trying to make this script but instead of the asteroids going sideways I want them to go down so I did that but now the asteroids are going down on one line. In the "deployAsteroids" script I have tried to change "screenBounds.x * -2" to "screenBounds.y * -2" I have also tried to change the Random.Range screenBounds to x instead of y. Btw I am a beginner coder so I am sorry if it is something obvious.
I encountered a problem here. my clone of asteroid spawns for a few miliseconds, then after the main one get destroyed, no clone spawns..'
same
My Object Doesn't spawn any help please
I’m am working on a project for college and this really helped me out, however I’ve been trying to connect it alongside a network manager and I can’t get the second asteroid script to work like they just don’t spawn in. Any tips?
My unity doesnt allow me to add onto my deloyasteroid script qwq idk how to make it work and its the same code used here
The screenboundaries code is correct, it should be something like this:
if (transform.position.x + screenBounds.x < 0)
does this also work up and down? not just left to right
It doesn’t say any errors but it won’t spawn the asteroids
Thanks man!
awesome video!
thank you!
sir How can i apply such CODE in an 3d runner game when camera is from behind
i have the same question
Can you make it so that the clones get slowly faster the longer you play?
my enemies just seem to glitch off the other side of the screen, without appearing in the game view at all; any help
Is your camera moving or is it static?
@@pressstart6864 It appears static, but it turns out it's technically moving? I tried the code you suggested to someone having a similar issue and it resolved my problem :)
@@pressstart6864 I have the same issue. My camera is moving
@@caseymckinney8377 what was the code you used to fix this issue
@@JaquanGrand I had the same problem, idk why.
I destroyed the item with a timer, instead of screenbounds
Thanks for the video.
Is there any problem of moving the player X or Y on a infinite runner instead of keep the player stood still and move the bg?
my game stop because the original asteroid that i put in the the deploy asteroid is missng
my prefabs are spawning only on one Y position whats the problem
How would you try giving the spawning transforms of the 2nd spawning object a bit of a minimum distance from the spawn transforms before?
What I mean more precise: I want to spawn several objects in a scene but they won't move nor disappear after they spawned. They should spawn in a pre-set area with a pre-set number of objects that spawn, but they should all have a minimum distance around them, so that the meshes won't overlap.
I'm still rather new to coding so I'm not always quite sure what can and can't be done, would appreciate the help ':D
Hi, how do i change the amount of objects spawned at a time i want to increase it as the game continues?
Thanks for the video! Just one question, why use this.GetComponent instead of just GetComponent? Thanks!
Is there a way to refresh the spawn boundaries?
how to spawn an item only if previous one is already collected ? if is not then dont spawn
You are the best!
My missile disappears instantly once I run the game, any ideas? :/
is there a way to make in go from top to bottom instead of right to left
Replace every “x” with “y”
my object disappears in the middle of the screen and I want it to be from top to bottom
In asteroid.cs, change this line to move from top to bottom:
rb.velocity = new Vector2(0, -speed);
and in deployasteroid.cs change this line to have it appear above the camera:
a.transform.position = new Vector2(Random.Range(-screenBounds.x, screenBounds.x), screenBounds.y * -2);
@@pressstart6864 hey buddy, how to make more than 1 object to spawning? not only asteroid,, please help me
My asteroids fly on for quite awhile after leaving the screen before being destroyed. Does somebody know why that is?
How can i make the clones spawn inside of a canvas?