How do you Make Respawning Obstacles?

I’m very new to Unity and I’m looking to practise but I need some help first!

I’m creating a simple game similar to Temple Run where the obstacle moves towards the player and the player has to dodge/jump over the obstacle.
How can I make it so that the two obstacles respawn (not in order) when they pass the player and the game ends when the player gets in contact with the obstacle?

Using C#

I’d really appreciate the help, thank you!

2 Answers

2

Did you look on the Asset Store? If you’re a beginner wanting to learn to make a game using Unity and you’re not using the Asset Store, then you’re missing a trick.

There are several full template projects for 3D infinite runners, which will not only show you how to spawn the obstacles, but many other aspects of developing a game. I’m not going to recommend one, but I strongly suggest you take a look:

Thank you for your help.

First you have to move your main character not whole environment.
You have to place colliders to detect that player cross that regions.

For this OnCollisionEnter or OnTriggerEnter method become useful to you.

Based on this collision detection you have to respawn objects at new position. Also for game over these only methods become useful. You have to assign tag to each object and based on tag you have to detect about game over or other thing.

You also have to look at other ready made template available in asset store. Some are free of cost so you don’t have to pay for learning purpose.

Thank you for the assistance.