Search Unity

Infinite Runner Starter Pack

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

  1. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    Hi Opsive, quick question. How would I go about removing the fog in the curved diffuse shader?
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Open up Diffuse Curve.shader and change the last line of the fragment shader from:

    Code (csharp):
    1.  
    2. return lerp(color, _FadeOutColor, max(i.distanceSquared  / _FarCurve.z, 0.0));
    3.  
    to
    Code (csharp):
    1.  
    2. return color;
    3.  
    You can then remove the two lines in the shader that mention _FadeOutColor.
     
  3. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
  4. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    Hi Opsive, is there any particular reason why my scenes disappear when I link a platform to them? The platforms show up perfectly fine, but my scenery disappears....
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Does the scenery spawn and then disappear? Or does it just not spawn at all? If it doesn't spawn at all chances are there is a rule or probability that is preventing it from spawning.
     
  6. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    Thanks for your reply, the scenes did not spawn at all, none rules set up. . After I reassigned the scenes to the Infinite Object Manager the problem was solved :)
     
  7. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    Been busy working on my project today, here is a screenshot of my progress so far, really enjoying the robusteness AND flexibility this package offers.



    I do have another issue I ran into:
    - The colliders of the moveable objects (in this case the cars that drive) do not seem collide with the player, he runs straight through them. I double checked all settings and components with those of the prefab moveable objects (canonball) and I am pretty sure they are identical.
    - The same for the jump platform in the top screen, I set everything up collider wise (even copied and resized the colliders from on of the jump platform prefabs), and the player falls straight through it. The auto jump collider works, as soon as the shield upgrade is selected he auto jumps over the platform gap...

    Any idea what could be causing this?
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Thanks for posting a screenshot - it's looking great so far! Keep us updated as you progress.

    In terms of the collision issue, when the player collides with an obstacle, the OnTriggerEnter event is called on the ObstacleObject. This then checks to make sure the colliding object is the player (using the Player layer). If it is the player then the collision occurs. You may not get these collisions if your layers are set incorrectly, your objects don't have a collider, or your objects don't have a rigidbody. The rigidbody is pretty easy to forget but it is necessary as Unity won't generate the collisions if that rigidbody isn't there.

    Because you said that the character can collect power ups and automatically jump, my guess is that everything is setup properly on the character. Double check your obstacles to verify that it is the same as the included obstacles, especially looking for the layer, collider (with Is Trigger set to true), and the rigidbody (with Is Kinematic set to true).
     
  9. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Hi, Hope you are doing good.
    How do I force the obstacles to spawn in different slots. Right now it spawns one after other in same lane of a platform leaving blank space in other two platform. I want like this, if the platform have three obstacle to spawn it should spawn it in three different lanes.
    Thanks
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    It already spawns obstacles in different slots per platform, but each platform is independent of each other so as you can see there is a chance that two immediate obstacles will both spawn in the left slot. I don't have an answer on how to accomplish this right now, but I'll definitely add it to the next version.
     
  11. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi@opsive I ran into a little problem, I have made seamless textures for platforms and any other assets which needs to be repeated, but when my platforms are repeated then there is dark seam/line that is visible from a distance but when it comes closer it disappears. Same happens with cars, I have overlapped the Uvs for the mirror side, when the cars spawn then a seam is visible in the middle of the car but when it comes closer the seam disappears.
    Please Help!
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
  13. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    yes I have increase the aniso level to the highest but it dsnt help.
     
    Last edited: Nov 4, 2014
  14. TheLetterS

    TheLetterS

    Joined:
    Jan 22, 2013
    Posts:
    31
    Hi @abhishek1191, I did the art for the Infinite Runner Starter Pack and I think I know what you are talking about. I've run into that issue a couple of times as well. The solution that worked for me is in the texture map to either extend the textures past the actual unwrapped uv edges of your object, or move the uv edges further in if that makes sense. Basically it can be caused by the uv lines being right on the edge of the texture map and for some reason giving more room helps. Let me know if that works for you!
     
  15. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi @TheLetterS Giving room to the UVs worked out nicely. Thankyou :)

    @opsive I have attached coin groups with the obstacles, now the obstacles spawn correctly every time but the coin group with them doesnt, sometimes it spawns all the coins in the group and smtimes some of them are missing. Any idea that what must be going wrong there?
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Good catch. Open CollidableObject.cs and change SetParent from:

    Code (csharp):
    1.  
    2.   CollidableObject childCollidableObject = null;
    3.   for (int i = 0; i < thisTransform.childCount; ++i) {
    4.     if ((childCollidableObject = thisTransform.GetChild(i).GetComponent<CollidableObject>()) != null) {
    5.       childCollidableObject.SetStartParent(thisTransform);
    6.     }
    7.   }
    8.  

    to:
    Code (csharp):
    1.  
    2.   CollidableObject[] childCollidableObjects = null;
    3.   for (int i = 0; i < thisTransform.childCount; ++i) {
    4.     childCollidableObjects = thisTransform.GetChild(i).GetComponentsInChildren<CollidableObject>();
    5.     for (int j = 0; j < childCollidableObjects.Length; ++j) {
    6.       childCollidableObjects[j].SetStartParent(thisTransform.GetChild(i));
    7.     }
    8.   }
    9.  
     
  17. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
  18. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    hi @opsive i was working on moving obstacles set and i notice that every time they spawn, they act differently. so how can i create instance of moving obstacle?
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Can you explain some more on how they act differently?
     
  20. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Hello,
    Whats the functions i need to call to add coins and diamonds please ?
    I will use them for IAP
    Also one quick question, the score, coins and diamonds are saved on the sceen or globally ? can i display them in other sceans instead of the main sceen ? if yes please ?

    P.S sent you an email days ago and i didint get a replay yet...
    Thanks
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Sorry about that, I don't have any unread emails in my inbox and just checked my spam folder and didn't see anything.

    To add coins and diamonds, all you need to do is call DataManager:AdjustTotalCoins(amount, primaryCoin) where amount is the amount that you want to adjust it by and primary coin indicates if it is a coin (true) or diamond (false). You can get an instance to the DataManger with DataManager.instance.

    The coins and diamonds are saved using PlayerPrefs. You can get the number of coins with DataManager:GetTotalCoins(primaryCoin) and display it on whatever screen that you want.
     
  22. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    I sent the email days ago not today, but its ok you already answered me here thank you :)
    I didint exactly get what you mean by "primary coin indicates if it is a coin (true) or diamond (false)"
    from what i undrestand if i want to add coins i call primaryCoin and if i want to add diamonds i call secondaryCoin ?

    And oh by the way, why the revive request/window only appear one time ? what about apearing many times and each time get the double ? (2 - 4 - 8 - 16 etc)
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    That is correct.
    You can change that by modifying DataManager:CanRevive. It just uses a bool to determine if the window has been shown but you can change it so it will always show if the player has enough diamonds. You can change the cost of the revival with DataManager:GetReviveCost
     
  24. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Thanks i will try it
     
  25. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Sorry im not into coding at all, i found the functions you refered to but how actualy get it to work ? for both alwayse apear the window + the cost start with the initial cost i set on Game gameobject then every next time is x 2, example if its 1, then it will give 1, 2 , 4, 8, 16, 32 etc each time, help please.
     
  26. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    To show the window everytime all i have to do is add "//" :D
    //hasBeenRevived = true;
    or ofcaurse keep it false.
    Now multilplaying the diamond cost
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    If you are new to scripting I highly recommend taking a look at the Unity Learn site on scripting so you can apply quick changes like this without having to wait for me to respond. :)

    To multiply the diamond cost you'll need to first need to keep a variable which keeps track of the number of times the player died. I would name the variable "reviveCount" and it should be a private int at the top of DataManager.cs:

    Code (csharp):
    1.  
    2. private int reviveCount;
    3.  
    You can then increment it within the CanRevive method:
    Code (csharp):
    1.  
    2. reviveCount++;
    3.  
    And finally use it to increase the cost within GetReviveCost:
    Code (csharp):
    1.  
    2. return (int)Mathf.Pow(staticData.reviveSecondaryCoinCost, reviveCount);
    3.  
    Make sure you set reviveCount back to 0 within ResetValues.
     
    Last edited: Nov 15, 2014
  28. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Thanks !
     
  29. ApolloServant

    ApolloServant

    Joined:
    Nov 19, 2014
    Posts:
    2
    Hi Opsive,

    can you please explain to us how would you go about changing the number of lanes from three to five? I don't think it was answered here yet
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    Take a look at this post. It gives a pretty detailed explanation on how to make the switch.
     
  31. ApolloServant

    ApolloServant

    Joined:
    Nov 19, 2014
    Posts:
    2
  32. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi @opsive I want to spawn a particular coin object on the platform on trigger enter, please tell me how to use this code to achieve that.
    Code (CSharp):
    1. obj = (GameObject.Instantiate(objects[localIndex].gameObject) as GameObject).GetComponent<InfiniteObject>();
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    You can get the object from the pool with:
    Code (csharp):
    1.  
    2. CoinObject coin = InfiniteObjectManager.instance.ObjectFromPool(localIndex, ObjectType.Coin) as CoinObject;
    3.  
    From there it has been instantiated/reused and you just have to position/rotate it correctly.
     
  34. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    @opsive Thanks for the reply.. one more question, I have made sets of obstacles, all the sets spawns correctly but some times when a set spawns it just vanishes before the player reaches there to cross it. It doesnt happens with just one particular, it can happen with any set. Please help!
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    That's tough to say - are you able to reproduce it with the demo scene? Are the objects being place back in the object pool - meaning they are reparented from the platform back to their original parent? Or are they still parented by the platform and just deactivated?
     
  36. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Hey when i added "DataManager:AdjustTotalCoins(amount, primaryCoin)" example :
    DataManager:AdjustTotalCoins(1000, primaryCoin)
    but i get an error : The name `AdjustTotalCoins' does not exist in the current context
     
  37. Sinhabros

    Sinhabros

    Joined:
    Aug 3, 2013
    Posts:
    15
    You must do DataManager.instance.AdjustTotalCoins(1000, primaryCoin)
     
  38. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Same problem :/
    Assets/SIS/Scripts/IAPListener.cs(72,41): error CS0103: The name `DataManager' does not exist in the current context

    I am using this plugin : https://www.assetstore.unity3d.com/#/content/12343
    Here is a video showing where i added the code following the tutorial (at minute 3:18) :


    Please help
     
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    @Sinhabros - thank you for trying to help. Your suggestion is exactly what I would have said.

    @SIV - Ah, I didn't realize you were using the standard version. That version doesn't have the secondary coins so it is a bit different. The following will allow you to adjust your coins:

    Code (csharp):
    1.  
    2. DataManager.instance.adjustTotalCoins(1000);
    3.  
     
  40. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    No im using the pro version of your kit, and even using what you last said still same issue :(
     
  41. Sinhabros

    Sinhabros

    Joined:
    Aug 3, 2013
    Posts:
    15
    @SIV : I think I know your problem. Since you are using an In-App Purchasing Plugin, the scripts are in the Plugins Folder. There is a particular order of what folders get compiled first. Here is a useful link that helped me when I ran into this issue:
    http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html
    So to answer your question, place all the scripts of this pack into a folder called "Standard Assets" (case sensitive). That should solve the problem!
     
  42. Sinhabros

    Sinhabros

    Joined:
    Aug 3, 2013
    Posts:
    15
    @opsive : How can you find the particular scene object on which the player dies. For example, if the player dies on the Village Jump scene, it should return that name.
     
  43. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    What pack ? infinite runner or the in app purchase plugin ?
     
  44. Sinhabros

    Sinhabros

    Joined:
    Aug 3, 2013
    Posts:
    15
    Sorry, I forgot to make that clear. It is the Infinite Runner pack you need to place into the Standard Assets folder.
     
  45. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    Thanks but it didint work :(
     

    Attached Files:

    • test.png
      test.png
      File size:
      155.6 KB
      Views:
      422
  46. Sinhabros

    Sinhabros

    Joined:
    Aug 3, 2013
    Posts:
    15
    You also have to place the script (or folder where the script is placed) into either the plugins folder or standard assets folder (i would recommend this standard assets)
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,630
    @SIV -

    The DataManager script is located in the InfiniteRunner.Game namespace so you need to make sure you are including that namespace.
    Code (csharp):
    1.  
    2. using InfiniteRunner.Game;
    3.  
    Also, based on your screenshot, unless PrimaryCoin is a variable you are going to have other errors. Set the second parameter for true to have it affect primary coins.

    @Sinhabros -
    The easiest way would probably be to just do a raycast within PlayerController:GameOver.
    Code (csharp):
    1.  
    2.   RaycastHit hit;
    3.   if (Physics.Raycast(thisTransform.position, Vector3.down, out hit, Mathf.Infinity, 1 << floorLayer)) {
    4.   Debug.Log("Hit " + hit.collider);
    5.   }
    6.  
    You can set the death trigger to have the same layer as the floor layer to make the village jump scene work with this as well.
     
  48. SIV

    SIV

    Joined:
    May 7, 2014
    Posts:
    182
    YES! i was expecting something like that but i wasnt sure what is it, because the script need first to know from where to call that function, thanks so much Sinhabros and opsive :)
     
  49. Dharma_raj

    Dharma_raj

    Joined:
    Jun 21, 2013
    Posts:
    109
    Hi Opsive, I am having a problem with the tilt. Right now when I tilt, the Player gets snapped to the position in x, I want it to move smoothly like Temple run.

    I dont know whether we can have turn up or down platform transitions, like climbing walls or buildings, run on top surface of the building, and falling down like they have in Spiderman Unlimited. Hope it would be a good feature.

    Thanks
     
    Last edited: Nov 25, 2014
  50. abhishek1191

    abhishek1191

    Joined:
    Apr 13, 2014
    Posts:
    47
    Hi @opsive as i told you earlier that its happens very rarely so i have been testing it for past 2 days to find the same bug but havent found it yet so i will let you know if i get it again.
    In the mean time there is this another question to ask: I made some of my own scripts for camera movement and spring jump and its working fine in my mac but as we make a build of it and test it on ipad, it is not working. it seems like OnTriggerEnter is not redirecting it to InputController.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. namespace InfiniteRunner.InfiniteObjects
    5. {
    6.     public class cameraenter : CollidableObject {
    7.  
    8.     private bool hitTheTrigger=false;
    9.     void Start()
    10.     {
    11.         hitTheTrigger=true;
    12.     }
    13.    
    14.    
    15.        
    16.     public void OnTriggerEnter(Collider other)
    17.        
    18.     {
    19.         if (other.gameObject.layer == LayerMask.NameToLayer("Player") && hitTheTrigger )
    20.         {
    21.             Debug.Log("hit");
    22.                 InputController.StaticVar=false;
    23.             //hitTheTrigger=false;
    24.            
    25.         }
    26.     }
    27.        
    28. }
    29.  
    30. }
    I also added #if (UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8) earlier to this code but it didnt work.