Search Unity

Infinite Runner Starter Pack

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

  1. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    @Dharma_raj - You can enable "Free Horizontal Movement" on the Input Controller and that will prevent it from using the slots. In terms of having a turn with the platform transition, you should be able to. Platform transitions are basically an extension to the appearance rules so it shouldn't interfere with whether or not it is a turn.

    @abhishek1191 - There isn't anything within the code that you posted that is platform specific. The Input Controller is more platform specific though so depending on what StaticVar does it may not be executing.
     
  2. Sinhabros

    Sinhabros

    Joined:
    Aug 3, 2013
    Posts:
    15
    Opsive,
    For some reason, the code you have provided does not work. Nothing is being printed to the console. Thanks.
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Make sure the bottom collider of your scene is using the "Floor" layer. Also, you could start the raycast from a little bit above the height of the player to ensure the character's position isn't below the floor:

    thisTransform.position + Vector3.up
     
  4. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Hi,
    How can we instantly jump or slide without the need for the animations to finish ?
    Right now when i slide then slide again fast, nothing happen ! just the first slide animation is played but the collider become small again, i am using the mecanim version, i tried 0.1 exit time from slide and jump animations but the problem still the same, how to fix that please ?
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    For jump you can set the "Repeated Jump Delay" parameter on the Player Controller. If this is set to 0 then as soon as the character lands they will be able to jump again.

    The slide animation is one continuous animation so you'll need to split it up into multiple states if you want to be able to reset the animation. For that I would have the states Enter Slide -> Slide -> Exit Slide, and then you can keep repeating the slide animation for as long as you want.
     
  6. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi @opsive I am working on turns and cross roads, the issue I ran into is that my own meshes of turns are not working like When I mark the turn right or left option in the inspector the the platform spawns but it just act as a straight platform.

    So I used your turn platforms and parented them to my platforms, it solves this issue. But the player is now able to turn as soon as it enters the collider of the turn platform, I want it to be able to turn only when it reaches the point where it has to take the turn. Please help!
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    In that case you'll need to add a TurnTrigger to the crossroads and make sure restrictTurns and restrictTurnsToTurnTrigger is enabled. This will prevent the player from turning until they reach that trigger. The downside of this is that it will also force the player to turn when at a crossroads and has the invincibility/speed powerup. To prevent that you can add something like the following to the turn trigger:

    Code (csharp):
    1.  
    2. public bool disableWithPowerUp;
    3.  
    Then within OnTriggerEnter:
    Code (csharp):
    1.  
    2.   if (disableWithPowerUp && PowerUpManager.instance.IsPowerUpActive(PowerUpTypes.Invincibility) && PowerUpManager.instance.IsPowerUpActive(PowerUpTypes.SpeedIncrease)) {
    3.     return;
    4.   }
    5.  
    You'll need to make sure you include the InfiniteRunner.Game namespace as well to get this code to compile within the Turn Trigger.
     
  8. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    @opsive Thanks dude! It worked.
     
  9. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi @opsive We ran into a new problem now. While testing out the all the platforms, obstacles and scenes just disappeared. When I checked everything in the infinite objects got turned off on its own. I have attached Screen Shot 2014-12-19 at 3.42.45 PM.png the screen shots of the hierarchy. Please help!
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Hmm I haven't seen that one before. I know that it may be hard to do, but is it possible for you to reproduce it with the included demo scene?
     
  11. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Ya sure I will try to reproduce it with the demo scene. Thanks!
     
  12. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Hi Opsive,
    How do I detect the player hits the obstacles in sideways? I want the player to die only when he collide into the obstacle from front. If he did it from side he should bounce back to the lane. Any ideas?
    Thanks
    Dharma
     
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Within the obstacle's on trigger enter you can determine the dot product between the player's forward direction and the direction of the obstacle. If the dot product is close to 0 that means the collision was on the side. You would do something like the following with OnTriggerEnter:

    Code (csharp):
    1.  
    2. if (Mathf.Abs(Vector3.Dot(thisTransform.forward, (other.transform.position - thisTransform.position))) < 0.1f) {
    3.    // On the side, don't collide.
    4. }
    5.  
     
  14. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    HI Opsive,
    Thanks for the idea. I've added your code in the obstacle trigger enter function and it is not working properly. Also based on the obstacle's rotation angles the debug log reacts in reverse. Do I need to make all the obstacles rotation values to zero. I did anything wrong?

    public virtual void OnTriggerEnter(Collider other)
    {
    bool collide = true;
    if (other.gameObject.layer == playerLayer && collideWithPlayer) {
    if (canBangOnSide) {
    if (Mathf.Abs(Vector3.Dot(thisTransform.forward, (other.transform.position - thisTransform.position))) < 0.1f) {
    // On the side, don't collide.
    collide = false;
    Debug.Log("Hit from side");
    }else {
    Debug.Log("No Hit from side");
    }
    }
    if (canRunOnTop) {
    if (Vector3.Dot(Vector3.up, (other.transform.position - thisTransform.position)) > 0) {
    collide = false;
    thisGameObject.layer = platformLayer;
    playerAnimation.Run();
    }
    }
    if (collide) {
    gameManager.ObstacleCollision(this, other.ClosestPointOnBounds(thisTransform.position));
    }
    }
    }
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    The 0.1 value was just a guess - you'll need to play with it to get an appropriate value. Also, you'll probably want to ignore the y position so change the dot product to:

    Code (csharp):
    1.  
    2. var direction = (other.transform.position - thisTransform.position);
    3. direction.y = 0;
    4. if (Mathf.Abs(Vector3.Dot(thisTransform.forward, direction)) < 0.1f) {
    5.  
     
  16. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi @opsive,
    I am using cross roads as just straight path i.e I hvnt activated turns on the cross road. I just want moving obstacles like traffic to come from the sides so the player feels tht he hs to cross a busy cross road. I have attached moving obstacles with the cross road..now by attaching it works only once..like the traffic come from the side when the cross road spawns for the first time. But then those obstacles fall off the platform and the next time cross road spawn it is without the obstacles. How should I go ahead with problem, please help!
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    When the crossroads spawns again, are the moving obstacles still a child of the crossroads and just not activated? Are you running the most recent version? There was a bug similar to this awhile ago but it should be fixed with the latest version.
     
  18. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    yes, they are active and still the child of crossroad but not in the correct position. we are using the latest version too.
    Actually i want to reset the position of moving obstacle when they are attached to a platform. Is there any way i can reset a particular obstacle through platformObject or may be just remove movingObstacle from infinite object and use it as platform child.
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Does the same problem occur with the demo scene? I just tried it, and the cannonballs were correctly positioned after the platform has been respawned.

    To help debug, you can insert a breakpoint within InfiniteObjects:Orient(PlatformObject, Vector3, Quaternion). When a collidable object is activated again Orient gets called and that will position the object back to the starting position. This should reset the position.
     
  20. AshwaniShinde

    AshwaniShinde

    Joined:
    Sep 27, 2014
    Posts:
    19
    hi...can anyone tell that how character1 clone and dragon clone r generate when i press play button......how it works....where is the code ............i m new in unity thats why i dont know
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Those objects are initially created when the GameManager starts, within GameManager.Start(). The methods SpawnCharacter and SpawnChaseObject do the spawning.
     
  22. AshwaniShinde

    AshwaniShinde

    Joined:
    Sep 27, 2014
    Posts:
    19
    thank u so much...........
     
  23. AshwaniShinde

    AshwaniShinde

    Joined:
    Sep 27, 2014
    Posts:
    19
    how can i add my own track in place of these one........sir plz tell me .....and in which format i import the track in unity...and how can i add it.....
     
  24. AshwaniShinde

    AshwaniShinde

    Joined:
    Sep 27, 2014
    Posts:
    19
    and what is the use of prefab.........why we create
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    The infinite runner documentation assumes that you have some Unity experience so I first recommend that you go through the Unity Learn tutorials. In particular, the Roll a Ball and Survival Shooter are good if you you are just getting started. From there you can watch the Using your own Assets video and that will show you how you can add your own objects.
     
  26. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Hi Opsive, One quick question, how do I make the infinite objects to spawn before Startgame calls. My camera is facing the horizon at the start up. For the first run I can see all the infinite objects, but in the next run I see only the startup object. After I hit play game button the infinite objects spawn suddenly which looks odd.

    Thanks
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    In the demo version the camera faces the opposite direction so when you hit play after a reset you don't even notice that only the startup objects are spawned. Since your camera is facing the 'correct' direction from the start you can spawn the remaining objects within GameManager.RestartGame immediately after ReadyFromReset (line 318):

    Code (csharp):
    1.  
    2.   infiniteObjectGenerator.ReadyFromReset();
    3.   infiniteObjectGenerator.SpawnObjectRun(true); // <- New
    4.  
     
  28. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Thank you so much Opsive!! Works well.
     
  29. AshwaniShinde

    AshwaniShinde

    Joined:
    Sep 27, 2014
    Posts:
    19
    i go throught those tutorial.........thanx to help me....but i can't add my own track .......how can i design and how to adjust and where i change to set my track in these project...........pls tell me.......i want to add my track in these project
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    You can use your own platform by setting the prefab under the Platforms array in the Infinite Object Manager. This video around 14:30 shows how, as well as this documentation.
     
  31. paskal007r

    paskal007r

    Joined:
    Sep 6, 2013
    Posts:
    66
    Does this package support unity's new gui system?
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Yes - the base package uses the free version of NGUI but there are included packages which use uGUI and NGUI 3.
     
  33. ambakamsurya

    ambakamsurya

    Joined:
    Jan 9, 2015
    Posts:
    1
    hi im new to this UNITY world. i have downloaded the infinite runner starter pack ..... Pls send me the tutorial for operating the game ..... im new to UNITY
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Welcome to Unity :) Take a look at this post for some links to some starting videos. I highly recommend that you first go through some of the Unity Learn tutorials first as that will dramatically decrease the amount of time that it takes to get your own game up and running.
     
  35. Uzair_Baig

    Uzair_Baig

    Joined:
    Jan 27, 2015
    Posts:
    1
    Hello Opsive, i am an artist trying to work on this Infinite Runner pack and have a query about coins appearance. I want the coins to appear in multiple lanes at the same time in the same position to get proper benefit from Coin Magnet Power Up, plz help me in this matter. I have not much understanding of coding.
     
  36. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,288
    @Uzair_Baig - please can you PM me your invoice for the Infinite Runner pack. I couldn't find your order in our database. It's possible your purchase was made using a different email address in which case your invoice will show that.
     
  37. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Hi Opsive,
    This question is regarding the NGUI system where I could able to tap two buttons at a time which results in opening two different panels. Also it calls quit and resume functions together when hitting the corresponding buttons simultaneously. Any help?

    Thanks
    Dharma
     
  38. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    779
    I think that would be an issue with NGUI more so that this kit. Have you tried searching/posting on the NGUI forums to see if anyone else has had the issue or can help? This would be the same issue on any project that uses NGUI. Sounds like you need to disable multitouch functionality within NGUI.
     
  39. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Thanks, But I tried disabling multi touch already. The problem not occurs when tapping multiple buttons at a same time, but when hitting the buttons one after another within fraction of a second.
     
  40. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    779
    Does NGUI have an input delay? So you cannot interact within x seconds/frames of the last interaction? Otherwise the Menu System will have to be updated to store which button was pressed and not allow another button to be pressed which overrides it. That would be an update for this pack.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    I did some searching to see if NGUI has any sort of input delay but I couldn't find anything so I just added it to the pack. It's a pretty quick change to make.

    Within GUIManager.cs add the following variables:
    Code (csharp):
    1.  
    2.   public float clickDelay = 0.2f;
    3.   private float lastClickTime;
    4.  
    Then add the following to Start:
    Code (csharp):
    1.  
    2.   lastClickTime = -clickDelay;
    3.  
    And finally add the CanClick method:
    Code (csharp):
    1.  
    2.   public bool CanClick()
    3.   {
    4.     bool canClick = lastClickTime + clickDelay < Time.time;
    5.     lastClickTime = Time.time;
    6.     return canClick;
    7.   }
    8.  
    You should then call this method within GUIClickEventReceiver.OnClick:
    Code (csharp):
    1.  
    2.   if (!GUIManager.instance.CanClick()) {
    3.     return;
    4.   }
    5.  
    If you are using a newer version of the infinite runner that has uGUI you'll need to also modify the GUIManagerInspector since it doesn't use the standard inspector. This is within OnInspectorGUI:

    Code (csharp):
    1.  
    2. DrawProperty(serializedObject, "clickDelay", "Click Delay");
    3.  
     
  42. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Hi Opsive, Thanks for the idea. Will it work on UIplayAnimations?
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    It should. You'll probably need to adjust the click delay value but the GUIClickEventReceiver isn't aware that the UIPlayAnimations component even exists so it should work.
     
  44. hluper

    hluper

    Joined:
    Jun 25, 2013
    Posts:
    16
    When you die in the game on a phone the revive panel is too large, how do I go about fixing this?
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    You should be able to just resize the revival panel no matter if you are using NGUI or uGUI.You can either scale that GameObject or use a new texture that has the correct aspect ratio.
     
  46. Trevinburgh

    Trevinburgh

    Joined:
    Jan 26, 2015
    Posts:
    29
    If I buy the Pro version, how feasible would it be to extend the gameplay? I'm thinking of things like different power ups, flame jets shooting periodically from the sides or floor, etc.
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Thanks for taking a look at the infinite runner. Those modifications are minor so it is pretty easy to make those changes. What type of power ups are you thinking of adding? For the flame it would just be a particle system attached to the platform or scene object.
     
  48. Trevinburgh

    Trevinburgh

    Joined:
    Jan 26, 2015
    Posts:
    29
    Thanks Justin. I was thinking of powerups that (for example) only work on certain types of obstacles; so you might be able to burst through wooden objects but still crash on metal or rock. But as long as there are hooks in the code for adding new powerups I can probably sort that out.

    On the flame jets I was thinking of more than just visuals but actually having them kill the player if he passes the jet at the wrong time. So effectively a periodic obstacle.
     
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,646
    Both of those are pretty easily possible.

    The power ups are controlled through the PowerupManager component. There is an enum that lists all of the power up types. For your new power up you'll have to define an enum and then within the ObstacleObject component you'd check to see if that power up is active. If that power up is active and the obstacle is the wooden crate you would not hurt the player because they ran into it (and play the bursting through wood animation). If the obstacle is metal or a rock then you would injure the player like normal. The code would be very similar to the invincibility power up.

    In terms of the flame, you would take a similar approach as the power up. If the flame is active then you injure the player, otherwise you let them pass without any damage.
     
  50. Trevinburgh

    Trevinburgh

    Joined:
    Jan 26, 2015
    Posts:
    29
    Thanks for the quick responses. I'm keen to produce something more than a reskinned clone and this sounds great.