Search Unity

endless running game

Discussion in 'General Discussion' started by IceWood, Oct 17, 2013.

  1. IceWood

    IceWood

    Joined:
    Jul 3, 2012
    Posts:
    30
    i want create endless running game ,so please give me some tutorials or some example projects
     
  2. Yoska

    Yoska

    Joined:
    Nov 14, 2012
    Posts:
    188
  3. IceWood

    IceWood

    Joined:
    Jul 3, 2012
    Posts:
    30
    thanks for your reply yoska.but what i want exactly means 3d runner game like temple run
     
  4. Yoska

    Yoska

    Joined:
    Nov 14, 2012
    Posts:
    188
    Sorry, I have never played Temple Run. But if you do that tutorial and if you just change the camera angle and add sideways movement then you should have great a blueprint/prototype for a 3D runner to build on.
     
  5. IceWood

    IceWood

    Joined:
    Jul 3, 2012
    Posts:
    30
    thank you yoska, great idea
     
  6. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
  7. ahaykal

    ahaykal

    Joined:
    Apr 18, 2010
    Posts:
    117
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I don't have a tutorial but I can give a high level overview of how you would design it.

    When created a game that includes procedurally generated content one of the biggest questions that you have to ask yourself is how do you decide what content to generate. In the case of an infinite runner similar to temple run, it is a little bit easier in that you are just deciding what prefabs to spawn versus creating the mesh/textures procedurally. Now, to spawn those prefabs you could do something as simple as taking the prefab that has the highest Random.value value. However, with that approach you aren't going to have any order in which your prefabs spawn. You could then make it more complex and have prefabs spawn based on the location within the game or based on other previous prefabs that have already spawned. Going along with deciding what prefab to spawn, you also have to decide where to spawn the prefab as UNITY3D_TEAM alluded to. In the case of an infinite runner like temple runner it is pretty easy in that the next prefab should spawn right after the previous prefab (no need to use Random.Range in that case).

    Once you figure out how to spawn all of the objects, you will then need to consider what happens if a player is really, really good at the game. Vector3 uses three floats for the position. If the player is very, very out in the distance because they have been running a lot, you'll start to run into precision errors with the locations of the objects that are being spawned. When these precision errors begin you won't really notice anything (who really cares if one prefab overlaps another by 0.01m?), but as the player continues to run out into the distance these precision errors will become more and more noticeable (you'll definitely see the error when the next platform is 100m away from the one that you are running on). With all that said, the simplest way to solve this issue is to have the player stay in the same position and all of the other objects do the moving.

    I consider those two concepts the basics of a game within the infinite runner genre. Once you solve those issues you can then add the fun stuff: obstacles, coins, power ups, different characters, a store, etc. All of those features aren't specific to the infinite runner genre and there are probably plenty of tutorials (or code snippets) on how to implement them.

    Hopefully that will give you a quick overview on how to create an infinite runner similar to temple runner. That said, I've solved all of these issues in a starter pack that I've listed on the asset store at https://www.assetstore.unity3d.com/#/content/8949.
     
  9. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    The best thing to do when approaching a big task like this is to just break it up and do one "objective" at a time. Opsive gave an awesome overview of the general approach now you just need to figure out implementation.

    Start with the bare bones functionality.
    • Create a cube prefab and make it move toward your player.
    • then write a script that will keep generating new cubes as the previous cube moves forward.
    BOOM you have the basic functionality of an endless runner.

    After that you just keep adding functionalities like...
    • Allowing your player to jump
    • moving side to side
    • turning
    • powerups

    just take it one small bite at a time and before you know it you have a full game :D
     
  10. NDJoshi

    NDJoshi

    Joined:
    Jan 24, 2014
    Posts:
    1
    Hey,
    Thanx a lot for the solution...
    Can you please mention the C# code to generate prefabes and add those prefabs as they passes?
    It will a great help for me.
    Thanx in advance!!!
     
  11. DallonF

    DallonF

    Joined:
    Nov 12, 2009
    Posts:
    620
    Sounds like you need to do some more generalized tutorials to get yourself used to programming before you attempt a custom game.
     
  12. h-hassanalikhan

    h-hassanalikhan

    Joined:
    Jan 27, 2014
    Posts:
    6
    Hi all,
    I have just started writing tutorials for endless runner game. you can find the tutorials on http://unitygamedevtuts.blogspot.com/. I will be updating the blog regularly. There you can ask related or general questions regarding Unity3d.

    Thanks
     
  13. Omer.Hussain

    Omer.Hussain

    Joined:
    Dec 16, 2013
    Posts:
    5
    Hi ! @TheValar I have created the main endless track .. but one thing i am not getting... i have made a road which works like in a circular link.. 1st end 2nd start , 2nd end the first comes in front of first... but when i add houses or trees around that road the game stuck a little in instantiating and removing process of the road... if i just add road it works fine but if i add houses besides the road it take a jerk ...
     
  14. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    686
    1.Store gameobject data in object space and use it runtime in worldspace.
    2.Use random class and other logic
    3.Use object polling.
    4.Do the transform check for overflow and adjust it properly.
     
  15. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,363
    Just round the position of each prefab to the nearest integer or 0.1. Problem solved.
     
  16. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,157
    Or keep the player's forward motion static and instead move the platforms themselves and make use of object pooling. Unless you're on a ridiculously tight memory budget, this would probably be more efficient.
     
  17. CaoMengde777

    CaoMengde777

    Joined:
    Nov 5, 2013
    Posts:
    813
    "cooking with unity" or "pushy pixels" on youtube, he has an endless runner tutorial
     
  18. GluedBrain

    GluedBrain

    Joined:
    Apr 12, 2013
    Posts:
    47
  19. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
  20. GluedBrain

    GluedBrain

    Joined:
    Apr 12, 2013
    Posts:
    47
    Glad that it helped you :)