Search Unity

Infinite Runner Starter Pack

Discussion in 'Assets and Asset Store' started by opsive, May 23, 2013.

  1. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Opsive, I've followed eactly like your video for using my own model. But when I start the game, the animations are not playing. I made all the animations in one timeline in 3ds Max and split them into clips in Unity.
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    First off, do they play when you preview them in Unity? Also, are you using mecanim or legacy? Any errors? You can start debugging within the PlayerAnimation:run method.
     
  3. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Yes, they play in preview. I'm using legacy. No errors.
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Put a breakpoint/debug statement within PlayerAnimation:run to make sure it is being called. It is probably going to take a few steps to narrow down the problem so if you want to just send me your project I can take a quick look at it and tell you what is wrong.
     
  5. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Tried, it's being called. I noticed in your character model, your animation clips start from, e.g. -1 to 19? When you did your animation, you did it all in one timeline?
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I need to check with our artist but I think so. If it plays within Unity it should be able to play with the starter pack.

    As a test make a new scene and add this class to your character. Make sure you remove any of the infinite runner scripts to prevent errors. We are just testing to see if the animation works:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class AnimationTest : MonoBehaviour
    5. {
    6.    public void Start()
    7.    {
    8.       animation["RUN_ANIMATION_NAME"].wrapMode = WrapMode.Loop;
    9.       animation.Play("RUN_ANIMATION_NAME");
    10.    }
    11. }
    12.  
     
  7. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    It works if there are no other components other than Animation.
     
    Last edited: Apr 11, 2014
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Edit: Post above was edited, no longer applies
     
    Last edited: Apr 11, 2014
  9. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Sorry, I edited my previous comment.
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    So somehow the components that you are adding to it are messing with the animation. It's hard to say without actually seeing the model.
     
  11. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    I have another problem. I accidentally made my model and animations facing 90 degress left. When I rotate it by 90 degrees on the Y-axis in Transform to face the right way, I get this.

    $Position Problem.jpg
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Just parent the model with a game object that is facing the correct direction and attach all of the scripts to that game object. That way it doesn't matter what direction the character is facing.
     
  13. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Animations working now. Tried using game object same problem. My character at rotation (0,0,0) is facing left like this.
    $Menu.jpg

    When I rotate it by 90 degrees on the Y-axis in Transform to face the right way, I get this when I start the game.

    $Position Problem.jpg
     
    Last edited: Apr 12, 2014
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Can you post images of what your object hierarchy looks like for the character? Include the inspector for both the parent game object and the game object that has the model. The parent game object should make it so it doesn't matter what orientation the model has.
     
  15. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    My parent game object (SoldierHolder) doesnt have any components. My model prefab (Soldier) is the child.

    $Object hierarchy.jpg
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That's the problem - the parent game object needs to have the components so it will be the one that is aligned. Move over all of the components to the new parent game object.
     
  17. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    How about the Animation, Rigidbody and Collider components?
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Yes, the PlayerController needs those on the same game object otherwise it won't be able to find them,
     
  19. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    I dont fully get it, could you show me an example please? Could it be because of a script, that whenever you try to rotate the model from it's default 0, that it causes this problem?
     
    Last edited: Apr 12, 2014
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Basically what you need to do is go from:

    $before.PNG

    to:

    $after.PNG

    I just tested this out and it will work except you actually do need the animation component on the original game object. In this example my "Parent" game object still has the animation component. The character1 game object then contains all of the other components. The only code change that you will need to make is make it so that the PlayerAnimation script can access the animation component since it is no longer local to the same game object. Change line 31 of PlayerAnimation.cs to:

    Code (csharp):
    1.  
    2. public Animation thisAnimation;
    3.  
    This is instead of making it private. Then com,comment out line 43. Back in Unity make sure you reference the correct component within PlayerAnimation:

    $animation.PNG

    And you should be good to go. You can then rotate the parent game object however you want so the character is always facing forward.
     
  21. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Thanks, will try. Sorry I'm asking so many questions, I'm a newbie at this.
     
    Last edited: Apr 13, 2014
  22. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Opsive, after my slide animation is played finish, the character is moved below the floor, and is stuck at that position. Other animations do not cause this.

    $Position Problem 2.jpg
     
    Last edited: Apr 13, 2014
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Does your slide animation contain any vertical transform changes? If you take a look at PlayerController:changeSlots you'll see that it doesn't change vertical positions or adjust the colliders at all so I am wondering how it gets to that state.
     
  24. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Yes, my animation has vertical changes. It starts out straight and then I rotate the biped and move it down.
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Is there a reason why you are moving it down? Your animation should have a net vertical change of 0 otherwise you'll get what you are experiencing. If you really want to move it down then you'll have to adjust the code to account for that.
     
  26. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    I have to move it down. If not, it'll look like he's floating. My running animation moves the character up and down a little as well, but it's not causing this problem.
     
    Last edited: Apr 14, 2014
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Take a look at the character game object that you attached the PlayerController to. If the y position changes when you strafe then it is a bug with the starter pack. If the y position does not change then you need to take a closer look at your animations to see why it is doing what it is doing.
     
  28. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    My bad, the Y-axis of the character is not 0 in my animations.

    Edit: Fixed.
     
    Last edited: Apr 15, 2014
  29. StephenAS

    StephenAS

    Joined:
    Mar 12, 2014
    Posts:
    16
    Hey Opsive,

    I'd like to change the obstacle spawning code, so that the next platformObject after a turn doesn't include obstacles. Whats the best way for me to make that change? (sort of like transitions, but not distance based since the turns aren't distance specific) Would I be able to do this in the SceneAppearanceRules or would I need to change this in the InfiniteObjectGenerator?
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The easiest way would probably to setup a rule to prevent your obstacles from spawning after a turn platform. On the Obstacle Appearance Rule I would do this for each platform:

    $rule.PNG

    This will say that there has to be at least one object in between itself and the turn object before it can turn. You could also set the minimum distance to whatever the distance is of the platforms.
     
  31. StephenAS

    StephenAS

    Joined:
    Mar 12, 2014
    Posts:
    16
    Awesome, thanks opsive!
     
  32. loyalpenguin

    loyalpenguin

    Joined:
    Mar 5, 2013
    Posts:
    16
    Hello Opsive,

    First off, great job on this starter kit. Keep up the great work. Secondly I had a question on importing a character using Mecanim. I was using the free Robot Kyle model from the Asset store to kind of get a feel for adding in a character. Now I extracted the mecanim version like you mentioned but I can not get the robot to work properly.

    Basically I want to use the same animations that are applied to the knight but on the robot. So I duplicated everything that was in the Character1Mecanim prefab. The only thing that I was not able to duplicate was the Model file for CharacterMecanim. which I noticed was imported with animations.

    So when I run the game the character loads and he is running the idle animation, but when you start the game he just falls through the floor and remains in the idle animation. Could you provide some info on how to add in a mecanim character?
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Happy to hear that you're enjoying it!

    Here's a short video showing how to get Robot Kyle working with mecanim. Before the video started I already set the character1mecanim prefab to spawn within the StaticData component. Other than that this video should show you step by step how to get it working:

    https://www.dropbox.com/s/j3kc8gdb3m90za0/mecanimKyle.avi

    It was a little laggy after I hit the start button but it should be enough to show Robot Kyle working.
     
    Last edited: Apr 18, 2014
  34. loyalpenguin

    loyalpenguin

    Joined:
    Mar 5, 2013
    Posts:
    16
    That works great. Thanks for making the video on short notice.
     
  35. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Opsive, using the Infinite Runner/Diffuse shader makes the textures brighter, how do I prevent that?
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    What are you comparing it to? The standard diffuse shader is actually brighter than the diffuse curve shader because the diffuse shader takes into account the realtime lights whereas the diffuse curve shader does not:

    Diffuse Curve (included):
    $diffuse curve.PNG

    Diffuse (Unity shader):
    $diffuse.PNG

    If you aren't using any light mapping then the diffuse curve shader is a standard unlit shader. The color that appears in the game will be the exact color of the texture (again, as long as you aren't doing any light mapping).
     
  37. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    I'm using light maps.
     
    Last edited: Apr 19, 2014
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Is there a light map?
     
  39. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    But I tried with no light maps, the texture I imported (using unity diffuse), not the infinite objects texture becomes brighter when using the Infinite Runner/Diffuse shader.
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    It probably relates to the lights/shadows that the diffuse is using. I bet you'll have more similar results if you compare the diffuse curve shader to the unlit shader. Regardless, I have a version of the unlit shader that takes into account realtime lights along with some other features such as bump mapping and specular. I'll send you a PM with this shader.

    Edit: can you enable PMs within your profile or send me an email so I can send you a link to the shader?
     
    Last edited: Apr 19, 2014
  41. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    PM enabled.
     
  42. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Opsive, I've set the camera position in the Player Controller script to make it first-person. But when I click restart in the pause or game over menu, the camera seems to have moved back, it's ok if I return to main menu and start.

    $Camera prob.jpg
     
  43. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Opsive, check your PM, I've sent you the invoice.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thank you.

    Because you have a slightly different setup I don't think you need all of the code within the CameraController:startGame method. Try replacing the block within if (fromRestart) to:

    Code (csharp):
    1.  
    2.             targetPosition = inGamePosition;
    3.             targetRotation.eulerAngles = inGameRotation;
    4.             transitioning = false;
    5.  
     
  45. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    I'm using v1.33's code, so there's no inGamePosition or transitioning. I plan to update later.
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Version 1.3.3 was such a long time ago. I am only able to support the latest version, otherwise I would spend all of my time looking at code that has already been improved on in a later version. I recommend updating sooner than later. Version 1.4 had a complete rewrite of the Infinite Object Generator, and version 1.5.1 had a complete rewrite of the Player Controller.
     
  47. areszues92

    areszues92

    Joined:
    Dec 16, 2013
    Posts:
    78
    Ok, I'll update.
     
  48. harschell

    harschell

    Joined:
    Sep 20, 2012
    Posts:
    19
    Hi @Opsive,
    I braought your Infinite Runner Pack on 28th of Jan 2014.
    Its Really Great asset to learn n use.
    As per my project requirement I customized it...
    I'm trying to build a game which has combinations of subway surfer + temple run series + Pitfall like features...

    I've some queries for you...​


    1. How can I generate tracks with Control randomness?
    Say I've Platform_01 to Platform_10 w.r.t Scenery_01 to Scenery_10 for one say jungle environment. I've same number of platforms and scenery for other 4 environments. I used your sections 0 to 4 all generating good n nice environments but i want to avoid randomness.
    What i want is i want for environment one :: Platform_01 should be followed by Platform_02 then by Platform_03 then Platform_04 then Platform_05
    I want to add controlled randomness to probability so that i can easily adjust it as per my need!

    2. How Can I chang from One environment to another say using portal or some thing like that?


    3. Subway Surfers Coins System ?! How can I make Coins placement system as same as " Subway Surfers "?
    I'v noticed in the endless runner game " Subway Surfers "
    that the coins that the game spawning isnt a random range . its like they are sit to spawn that way ,
    For Example they spawn when there is free land without trains , or on the train it self and moves with it ,
    or it spawns between 2 trains and so u can jump and get them ,
    and when u get faster and faster , the coins position gets more wide , it changes with the speed ,
    coz the more speed makes the more and wide jump ,

    how is that possible ?! any ideas ?!

    4. Can we use rewind time/time bending feature with infinite runner pack? Is that feasible? How?


    5. Need Much needed Advice on Below mentioned issue please go through it::: I'm using Forest like realistic environments; my one prefab of dummy assets having 12-15 materials on average.
    iTs increasing draw calls to alarming levels say more than 120 ++ to 200 sometimes 250+ as well even after using baked lightmaps n removing every active light from game.
    Which makes it unplayable on mobile devices?
    Is there some specific art style with which i've to go? How can I reduce draw calls? thus this many materials from one single prefab?
    What kind of art assets I should use?
    There's No information about art in docs... and its really headache for me to explain these things to artist....
    Even thought i've managed to rum one 80 Mb build on high end android + iOS devices ;) :cry: for time being but when i'm going to use actual assets it will be very heavy :( So please guide me in this [game art] aspect too. As i don't know much about 3d models How should they be made to get reduced amount of textures + materials + shaders So game will be running smooth on many devices...

    I know I may be asking to0 much...
    Hope to get your reply soon....


    Regards,
    HBK
     
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Hi HBK,

    Lets see how can well I can answer these -

    1. In version 1.6 I am going to be adding a rule that will allow you to specify a certain object to spawn after another object, but for now you should be able to make a probability adjustment rule that basically says Object B will have a 99999x greater chance of spawning after object A. Obviously there is a very, very, very small chance that Object B won't spawn after A but you can basically say it will.

    2. You could use sections make your transition scene a portal.

    3. All you need to do is add the coins to the scene/obstacle prefab and they will always spawn with that prefab. Don't add the coins to the infinite object manager and they won't spawn randomly.

    4. I have never tried but the rewind feature works by basically storing a history of important object information such as position/rotation. Specific to the starter pack you are going to need to store the player's transform/speed at discrete time intervals as well as a history of the objects spawned so you can rewind the infinite object generator after it has recycled an object back into the object pool. This is a pretty major addition so you should have a really good understanding of how the core components (Infinite Object classes and Player Controller) work before you start making changes.

    5. This is a pretty general unity topic. You'll get a better answer if you do some searching (such as this) but the major things are to use a texture atlas and avoid overdraw (the less transparent objects the better)
     
  50. StephenAS

    StephenAS

    Joined:
    Mar 12, 2014
    Posts:
    16
    Hey Opsive,

    I just want to say thank you for such a great Asset Store pack and fantastically quick and indepth support on the forums. It's allowed me to release Super Heist Escape, in a ridiculously short development cycle that I would not have been able to do without this pack.

    http://www.superheistescape.com