Answer the question
In order to leave comments, you need to log in
I'm making a 2d space shooter how to spawn objects that will spawn in random places?
There is a blue block, this is a spawner, I want meteorites to randomly spawn for my 2d game, please tell me how this can be done? I will be very grateful)
Answer the question
In order to leave comments, you need to log in
I think you are doing this project for study. Then it will be more useful if you think for yourself.
To make it easier, I will give you a few scripts from the piggy bank of experience)
Timer
public float interval;
private float timer;
void Update()
{
timer -= Time.deltaTime;
if (timer <= 0)
{
timer = interval;
// делаем что-то
}
}
public GameObject toSpawn;
void Start() //start не принципиально, можно использовать любой другой нужный вам метод
{
Instantiate(toSpawn, *position*); // * не писать, просто позиция в формате Transform
}
Random(min, max);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question