Search Unity

  1. Full schedule for #UniteBerlin is now available! Featuring talks on our roadmap, hands-on labs and much more! Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Endless Runner Sample Game Q&A

Discussion in 'Community Learning & Teaching' started by Aurore, Aug 15, 2017.

  1. Aurore

    Aurore

    Producer Unity Technologies

    Joined:
    Aug 1, 2012
    Posts:
    3,101
    This is the official thread for discussion, issues and Q&A for the Endless Runner Sample Game (Trash Dash)

    Please use this thread if you have any questions, issues or feedback on this project.

    This is a project we have released on the Asset Store

    We also have a user guide in the Instructions of the project, as well as on our Learn Site



    We have also released this full game on the Google Play & App Store with all the proceeds of the game going to Game Changer charity.
     
    Last edited: Aug 15, 2017
    Kasaie and Mauri like this.
  2. f1b0n4cc1

    f1b0n4cc1

    Joined:
    Aug 27, 2015
    Posts:
    38
    Thanks for this project, it will help many game developers to improve their skills on Unity
     
  3. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    120
    Thanks for the project. I've only had a quick look, but the way some of the assets work confuses me. There's a red bin and a blue bin which share the same material and texture with no colour information. What is this voodoo?
     
  4. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    107
    Thanks for sharing this project, very interesting to see how a game like this is made.
    One question though, if I change the name of the asset bundle (Cat) from Trash Cat to anything else, the game loads but without the cat and throws and tells the object I want to instantiate is null. Where is the reference in the code for the name Trash Cat and how can I avoid this?
     
  5. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    Lots of objects in the project use vertex color (painted in the 3D software like maya/3ds/blender) to cut down on textures size (and because they all started as using only vertex color and some had textures added later when there was a need for more details).

    If you find the mesh (e.g. search for WheelyBinBody) you can see on the preview at the bottom the inspector that the mesh have uv and colors information per vertex.

    The shader (CurvedCode.cginc) then multiply the vertex color by the texture color (which is greyscale) allowing for varaition in tint across the mesh.

    To keep thing relatively simple, the game use the character name as the key saved in the save file to know which character is owned & used (to be more robust we could build some kind of unique ID system per character so you can change the name and retain the character, but that is left as an exercise to the reader :p)

    When the game create a savefile, it grant ownership of Trash Cat by default. So the game will try to instantiate the character called Trash Cat and will fail if it don't find it.

    To modify that, look for the PlayerData.cs script, and for the function NewSave() in that script. You will see there that we add to the character list Trash Cat (and to the theme list Day). You can change that to the name of your new character here so it work.

    *Note*: after modifying the script, you will need to Clear the save file (either through the Trash Dash Debug menu in the editor or in game, in the settings popup with the Delete Data button) so that the game regenerate a new one with the proper character added to the player save.
     
    Kasaie, theANMATOR2b and Shizola like this.
  6. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    107
    Thank you for the reply!
    That was easy enough, interesting to see how you handled that part of the game.

    Also, I'm trying to find how the pickups are being distributed on the track, but I can't seem to find where that's being done in the code?
     
  7. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    If you look in TrackManager.cs, there is a function called SpawnCoinAndPowerup() that take care of spawning the "coins" (here the fishbones), premium currency and powerup. It will pick a purcentage of chance that a powerup will be spawn instead of a "coin" (that purcentage grow with time, so that after a while we are sure to spawn one).
     
  8. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    120
    Can I ask how long it took you to make this project and how many people were involved?
     
  9. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    For the time it took, it is a bit hard to tell precisly because it was made in parallel with other thing, But I would reckon that combined, it was roughly 6 month of works from start of the project to release on store.

    As for the team, "full time" : one producer, one artist & one programmer.

    We had an animator who worked a couple of week for the animations and a contractor for sounds/music.

    Finally some "external" QA (i.e. not done by the full time team :D) was done at the end of the project before submitting on the stores by an additional person.
     
  10. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    120
    Thanks Guillaume, this type of information is always useful to me.
     
  11. parag1

    parag1

    Joined:
    Jun 14, 2017
    Posts:
    1
    Thanks for the project.I want to change cat character.Can you help me ?
     
  12. murataksu740

    murataksu740

    Joined:
    Aug 5, 2017
    Posts:
    1
    how add character?
     
  13. SamerNajadao

    SamerNajadao

    Joined:
    Aug 24, 2017
    Posts:
    1
    Thankssssss brother ❤
     
  14. EvgOst

    EvgOst

    Joined:
    Sep 23, 2017
    Posts:
    1
    Very interesting project. I want to change my runner on its basis. There are ишп differences in it: several characters in the scene at the same time + they can move to the right and left, that is, the track has not 3 positions but rather a large area on which the characters can move. Where can I start the changes? Where can I change the parameters of the track? Characters are probably changing in PlayerData.cs?
     
  15. emi-albu

    emi-albu

    Joined:
    Aug 15, 2012
    Posts:
    9
    Is it possible to add a different track segment with a different curved rotation (given the current global shader)? Can you get the feeling you are changing direction like in the minion rush?
     
  16. en_ce

    en_ce

    Joined:
    Nov 11, 2017
    Posts:
    1
    Hi,
    Can I use the music used in this project on my own project? Do I encounter a copyright issue?
    Best regards...
     
  17. me_atif

    me_atif

    Joined:
    Dec 7, 2016
    Posts:
    2
    Hi Guys i am converting this game in WebGl but when i play it on local server xampp the character is not loading
    please help me
    i need your help urgently
     
  18. Riddlah

    Riddlah

    Joined:
    Mar 26, 2014
    Posts:
    19
    Hi. I have question regarding lighning used in Trash Dash. How it is implimented ? Even when I turn off directional light the game is lighted properly. So far as I saw, there is also no baked lightmaps. Can You tell me how it is implemented. I would also use proper mobile friendly lightning in my own endless runer, which also use pooling. Thank you for any answers. (Althought this thread seems inactive for long time :( )
     
  19. HappyCodeClub

    HappyCodeClub

    Joined:
    Feb 11, 2018
    Posts:
    1
    Everything in the project appears to be using the shader Unlit/CurverUnlit - I don't think there's any actual light being computed, the assets themselves were just created with bright-looking textures.
     
  20. grit

    grit

    Joined:
    Nov 12, 2013
    Posts:
    7
    I really enjoy exploring Trash Dash and I am learning a lot from it concerning the game structure and the track generation and such. Thanks a lot for providing such example projects!
    Also I find the curved shader very intersting. I am not very familiar with shaders (yet). I noticed that the curve is only intergrated in unlit shaders as far as I can see. Is it possible to apply the curve on shaders with lighting and / or combined with a Post Processing Profile e.g. Bloom, Depth of field etc.? And how? I fumbled a bit with putting "#include "CurvedCode.cginc"" into a lit shader, but I get an error message like:
    Shader error in 'Standard_gs': redefinition of '_MainTex' at Assets/Shaders/CurvedCode.cginc(21) (on metal)

    I don't really have a clue. Could you please point me into the right direction? Thank you!
     
  21. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    Note : you will require some basic understanding on shaders (what are vertex/pixel shader, model/view/clip space etc.) to grasp how the shader work.

    CurvedCode.cginc is actually nearly the full shader. It is put in a include file just so I don't have to rewrite the whole shader code when I just want to switch some parameter like Blending, Zwrite or the render queue etc.

    As you can see in the file, it define
    sampler2D _MainTex;
    chance are your custom lit shader already define that _MainTex smapler, hence the conflict.

    But what make the curving is just a part of the vertex shader in the CurvedCode include file :

    Code (CSharp):
    1. v2f vert(appdata v)
    2. {
    3.     v2f o;
    4.     o.vertex = UnityObjectToClipPos(v.vertex);
    5.  
    6.      //THIS PART----------------------
    7.  
    8.     float dist = UNITY_Z_0_FAR_FROM_CLIPSPACE(o.vertex.z);
    9.  
    10.     o.vertex.y -= _CurveStrength * dist * dist * _ProjectionParams.x;
    11.  
    12.     //----------------------------------------------------------------
    13.  
    14.     o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    15.  
    16.     o.color = v.color;
    17.  
    18.     UNITY_TRANSFER_FOG(o, o.vertex);
    19.     return o;
    20. }
    For each vertex of every object using that shader, it compute the distance of the vertex from the camera (UNITY_Z_0_FAR_FROM_CLIPSPACE) and use that distance as a ratio to offset it on the y axis in clip space (so the vertical axis).

    o.vertex.y -= _CurveStrength * dist * dist * _ProjectionParams.x;


    _CurveStrength is a float that is passed from script ( see the script WorldCurver.cs) so we can tweak the strength of the curving from a single point in the editor and we multiply by _ProjectionParams.x because some platform render with a flipped projection matrix, so negative y direction on some platform would curve the world upward. _ProjectionParams.x contains -1 on thsoe paltform, so the curve is happening in the right direction everywhere.


    So to use on it on a lit shader, either add that transformation in your vertex shader or if you're using a Surface Shader, add a vertex modifier function and do the same modification in that function (see here : https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html the section called
    Normal Extrusion with Vertex Modifier for an example of how to write such function)
     
  22. grit

    grit

    Joined:
    Nov 12, 2013
    Posts:
    7


    Thank you so much, UnityGuillaume! Your explanation is really clear and I can follow your description. However, I have to learn a little more about the subject in order to apply this effectively. But I am eager to do so. :)
     
  23. hamd95

    hamd95

    Joined:
    Nov 30, 2016
    Posts:
    6
    thank you Unity for this awesome project
    the problem that i faced, when i try to build asset bundle for android (by clicking on Build AssetBundles )
    i have the following error
    Type `UnityEngine.Networking.UnityWebRequest' does not contain a definition for `SendWebRequest' and no extension method `SendWebRequest' of type `UnityEngine.Networking.UnityWebRequest' could be found. Are you missing an assembly reference?
    so what's the solution in this case?
     
  24. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    Which version of Unity are you using? I think SendWebRequest was added in 2017.3 (but if you got it through the asset store in Unity, it should have given you a previous version)...
     
  25. hamd95

    hamd95

    Joined:
    Nov 30, 2016
    Posts:
    6
    yes i have Unity 2017.3.1f1
    should i update now for solving this error?
     
  26. hamd95

    hamd95

    Joined:
    Nov 30, 2016
    Posts:
    6
    In case of using bridge(or any thing to raise up, such as trains in subway surf), what should we add to code?
     
  27. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    It would require quite some modification, as for now, the system assume a single path for all 3 lanes (the character is just offset in the x position based on the lane. Based on where the character is, it ask the TrackSegement what is the position it should be + its lane offset.

    One possible solution (very broad overview) would be to modify the script TrackSegment.cs :

    The script track segment have a transform property called pathParent. It's a transform that will have children which will define a path to interpolate along. In the current game, this path usually have only 2 child : the entry and the exit and it interpolate between.

    But you could add 2 other transform pathParent : pathParentLeft, pathParentRight, that have more than 2 children and define your "elevated" path on each pathParent with as many gameobject you need, and modify the function GetPointAt so it can take a parameter telling the system on which lane you want the path to be interpolated, and select the good pathParent for that path, and in the character controller ask the position for the current lane on which the character is.

    (side note, if you want to display the new paths like it is now done with a blue line in the scene view, look at the function OnDrawGizmos from TrackSegement)

    Of course that's only part of what need to be done, by default it may act weirdly when changing lane from a high to low lane and vice versa, or jumping/sliding when changing lane etc...
     
    hamd95 likes this.
  28. hamd95

    hamd95

    Joined:
    Nov 30, 2016
    Posts:
    6
    It's done, but yes i get some weird results, where the camera change it's position if the bridge is not on the center lane
    Whatever, Thanx for help.
     
  29. Pepsidog

    Pepsidog

    Joined:
    Apr 13, 2017
    Posts:
    11
    How do you add custom characters and themes?
     
  30. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
  31. itamar87

    itamar87

    Joined:
    Aug 9, 2017
    Posts:
    1
    1.What is the purpose of using an UICamera in this project?
    All the canvas are in overlay render mode, so why did you add another camera?

    2. adding an UICamera would effect performances in some way?
     
  32. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    113
    1. It allow to display 3D model in a different position/scale etc. than the game Camera.

    Here it is used only for the character you see when selecting which character to play (if you look at the code you'll we assign it to the UI layer in the Loadout screen). We can have a point in front of the camera and just place the character here. Easier than to have to move the game camera just for the selection and place it back properly for the game.

    In the project, the UI camera end up using the same settings as the game camera, but a possible extension to that could be to play with FOV setting or stick post processing on it to make the character selection screen more interesting.
    We also had on "nice to have/try later" to display the level behind when selected, so it allow to display the character on top from a different perspective than the game camera (think overlay)

    2. It does but in a very negligible (read nearly non existing) way, because our UI camera have layer culling mask. it only display object in the UI layer (so nearly nothing, and the game camera don't display UI object, so no object are rendered twice) and render directly to screen on top of whatever was already rendered (so no setup cost of swapping render target etc..). The ratio : less code, easier to setup the shot over performance lost is clearly in favour of the ease of setup here
     
    itamar87 likes this.