Spawning Objects in Unity [Using Instantiate]

preview_player
Показать описание
In this tutorial I explain how to write a C# script that will allow you to spawn obstacles onto your scene using prefabs and instantiate.
============
In this video I will show you:
1:00 Adding a CircleCollider2D, Rigidbody2D
1:37 Adding a script to move the game objects
3:40 Removing objects from the scene once they leave the screen
5:00 Creating a prefab
5:40 Adding a script to spawn the objects
6:30 Using instantiate
8:25 Using Coroutines and IENumerator

COPY & PASTE SOURCE CODE:

MOBILE JOYSTICK VIDEO:

SCREEN BOUNDARIES CODE:

MORE TUTORIALS:
Рекомендации по теме
Комментарии
Автор

Sick tutorial, dude! I had this exact same question, except I'm new to Unity so I had no idea on what to do. This still holds up even 7 years later.

Bean_Lava
Автор

9:35 OK FINALLY I was so confused because nowhere could I find where you actually reference the prefab itself god bless you

Berniebud
Автор

I was searching for a solution for months and you explained it very finely.
I liked and subscribed. :)
Thank you. :)

figgi_myestrio
Автор

Bro, you're AWESOME. The only one in the whole World Whide Web who helped me out with exactly what I needed. Muchas gracias

julian_phoenix
Автор

it fixed my problem that i was having with my spawn system thanks a lot😎😎😎😎😁😁😁😁😁😁😁😁

loghanveilleux
Автор

Simply amazing. It's hard to find such a good quality tutorials like yours. Thanks a lot :)

tomsted
Автор

Hey man just wanted to say this was such a great help for me. You are awesome, keep it up!!

daichi_devs
Автор

This really helped me for my mini platform game assignment. Thank you!

psychospoiler
Автор

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?

erika_
Автор

Hey can anyone help me!
My Game Object (Asteroid) is spawning way behind the camera view and gets destroyed.

_pratyush
Автор

Idk if your still respone but i have an question how to let the astriod fly down unstat of to the left

vletsy
Автор

Thanq for the clear explanation.. It helped a lot :)

BhargavMarpu
Автор

hello from french,
thank you for tuto, you help me ^^
a good day.

RecréerMarioEtZelda
Автор

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?

boniebob
Автор

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.

nabilbensafi
Автор

How can I make more obstacles spawn through the progress of the game? Also great tutorial.

davidregalado
Автор

Did anyone else laugh when he said quarantine haha

setheywantfood
Автор

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?

amor
Автор

I was wondering how you would make the Asteroids spawn downwards vertically, instead of horizontally. Thanks.

milo
Автор

What is the best resolution to an image to get it to

cgnotavailable
join shbcf.ru