can someone guide to combine small parts to procedurelly generate a endless map(3d objects) and spawn random traffic as(moving obstacles) like frogger.
#a single part has roads and river etc.
Link: http://www.blogcdn.com/www.joystiq.com/media/2009/10/2009-07-16_16-48-12.jpg
Thanks,
Mansoor Cheema
There’s a whole endless runner video tutorial and tutorial project in the tutorials.
Make a script that tells an object to move left
Make a prefab of the object that’s going to be moving
Put the script on the prefab
Make a script that spawns the prefab some distance ahead of the player
Do the same for objects that move to the right, and you’ll have a start. There isn’t a lot to help you with code wise, just read through tutorials and how Instantiate works.
i want to create level by combining prefabs in random order to make unique map most of the time(10 prefabs).i can move on a single prefab but having difficulty to spawn a random prefab when player reaches end of the prefab i.e join a prefab at the end of a prefab (characater runs on prefab). the moving traffic problem is not present on a single prefab but to spawn from new prefabs which have joined with previous prefabs.
thanks
Make your spawning system part of the level prefabs t hat have things spawn in them. As for connecting prefabs… Line them up in the editor and take note of their relative positions. Then when you’re making a new level segment and it’s, say, a strip of road, you know that your road prefab is 6 units ahead of the current terrain.
You can parent the new road strip to the current section and set it’s local position to 0,6,0 which will put it a relative 6 ahead of the previous tile. You can then unparent it just in case unity doesn’t handle infinite parents well ![]()
If your prefabs are all different sizes, it’ll be a matter of lining them up in the editor to see where on the next prefab they will fit. You might be able to speed this up slightly if you put a transform on the ‘front’ end of your tiles which is the point the next tile will connect it’s ‘back’ to.