Search Unity

Puppeteer's Workshop

Discussion in 'Works In Progress - Archive' started by puppeteer, Dec 21, 2014.

  1. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Hello all,

    I've been making games and scripts for the Asset Store for a long time now, and it's getting a bit messy to keep track of individual threads for each project, so I decided to make this one big thread to post all kinds of progress videos and screen for anything new Puppeteer makes.

    Right now I'm working on several different things including a 4.6 UI update for my Tower Defense game, an integration of my Lockpicking toolkit into Realistic FPS Prefab ( by Azuline ), and a couple of new game templates.

    So here we go!
     
  2. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    treshold likes this.
  3. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    This is a work in progress of Astro Bouncer, a game template of the "avoid the spikes" game type. To be released on the Unity Asset Store as soon as I can.



    This was actually something I decided to make on a whim, after being stuck for several days in the logic code of another game I'm making. I just said "f**k it, I must release something before the month ends".

    Hope it gets done within the next couple of days.
     
  4. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's a piece of code I think might be useful for others. It's a basic waypoint-follow script that I'm using for my next project.

    Code (JavaScript):
    1. //This script makes the object follow a set of waypoints. You can set any number of waypoints, as well as the speed of the object. At the end of the path you
    2. //can set the object to either teleoprt to the starting point or move there normally.
    3. #pragma strict
    4.  
    5. internal var thisTransform:Transform;
    6. internal var initialPosition:Vector3;
    7.  
    8. //The object's movement speed
    9. var moveSpeed:float = 10;
    10.  
    11. //A list of waypoints to follow, and the index of the current waypoint
    12. var waypoints:Vector3[];
    13. var currentWaypoint:int = 0;
    14.  
    15. //Should the object look at the next waypoint?
    16. var lookAtWaypoint:boolean = true;
    17.  
    18. //Should the object be teleported to the first waypoint when it reaches the end?
    19. var resetAtEnd:boolean = true;
    20.  
    21. function Start()
    22. {
    23.     thisTransform = transform;
    24.  
    25.     initialPosition = thisTransform.position;
    26. }
    27.  
    28. function Update()
    29. {
    30.     //If we haven't reached the next waypoint, keep moving towards it
    31.     if ( thisTransform.position != initialPosition + waypoints[currentWaypoint] )
    32.     {
    33.         thisTransform.position = Vector3.MoveTowards( thisTransform.position, initialPosition + waypoints[currentWaypoint], moveSpeed * Time.deltaTime );
    34.     }
    35.     else //Otherwise, set the next waypoint
    36.     {
    37.         //Cycle through the available waypoints
    38.         if ( currentWaypoint < waypoints.Length - 1 )    currentWaypoint++;
    39.         else
    40.         {
    41.             currentWaypoint = 0;
    42.        
    43.             //Reset the object to position of the first waypoint
    44.             if ( resetAtEnd == true )    thisTransform.position = initialPosition + waypoints[0];
    45.         }
    46.    
    47.         //Look at the next waypoint
    48.         if ( lookAtWaypoint == true )    thisTransform.LookAt(initialPosition + waypoints[currentWaypoint]);
    49.     }
    50. }
    51.  
    52. //Draw the waypoint path in the editor
    53. function OnDrawGizmos()
    54. {
    55.     for ( var index:int = 0 ; index < waypoints.Length ; index++ )
    56.     {
    57.         if ( Time.time > 0 )
    58.         {
    59.             if ( index < waypoints.Length - 1 )    Gizmos.DrawLine( initialPosition + waypoints[index], initialPosition + waypoints[index + 1]);
    60.             else if ( resetAtEnd == false )    Gizmos.DrawLine( initialPosition + waypoints[index], initialPosition + waypoints[0]);
    61.         }
    62.         else
    63.         {
    64.             if ( index < waypoints.Length - 1 )    Gizmos.DrawLine( transform.position + waypoints[index], transform.position + waypoints[index + 1]);
    65.             else if ( resetAtEnd == false )    Gizmos.DrawLine( transform.position + waypoints[index], transform.position + waypoints[0]);
    66.         }
    67.     }
    68. }
    Here's what it looks like:
     
    Last edited: Dec 29, 2014
    theANMATOR2b likes this.
  5. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Astro Bouncer Game Template is finally RELEASED!

    LINK TO PRODUCT PAGE




    I've been waiting for this one to be accepted since Christmas. It was probably not a good time to upload new stuff because everyone would be on holiday, but it's finally out so that's nice.
     
  6. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    I just updated Astro Bouncer to 1.03, tweaking some of the gameplay elements and sounds, and reducing the package size significantly. I also made sure the start menu buttons works correctly for gamepads and keyboards.

    Tip: It turns out saving Flash files over and over again can bloat the file size to monstrous dimensions. The solution is simply to use Save As when saving the file, which will remove any extra size bloating it may have. This has helped me reduce an FLA files from 30mb to 15mb. Huge difference!
     
  7. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    Still waiting for RFPS update to hit the asset store. Really looking forward to it.
     
  8. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    I'm working on it, I promise!
    There are lots of things in the pipeline this month including updates for all packages and a couple of new games :D
     
  9. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's some work in progress for a Road Crossing Game Template I'm about to finish:



    There's not much left to do, just a death line, code comments, documentation and it's up in the store.

    Usually I work on several files simultaneously, so it's not always obvious ( for me ) which one will make it to the finish line first. This month it looks like the Road Crossing Game Template made it. Now I have some time to work on updates for existing packages.
     
  10. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
  11. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    I'd like to share a little script which could make your game model a little more varied and interesting for the player:

    Code (JavaScript):
    1. //This script randomizes the scale, rotation, and color of an object
    2. #pragma strict
    3.  
    4. //The range of the rotation for each axis
    5. var rotationRangeX:Vector2 = Vector2(0, 360);
    6. var rotationRangeY:Vector2 = Vector2(0, 360);
    7. var rotationRangeZ:Vector2 = Vector2(0, 360);
    8.  
    9. //The scale of the rotation for each axis
    10. var scaleRangeX:Vector2 = Vector2(1,1.3);
    11. var scaleRangeY:Vector2 = Vector2(1,1.3);
    12. var scaleRangeZ:Vector2 = Vector2(1,1.3);
    13.  
    14. //Should scaling be uniform for all axes?
    15. var uniformScale:boolean = true;
    16.  
    17. //A list of possible colors for the object
    18. var colorList:Color[];
    19.  
    20. function Start()
    21. {
    22.     //Set a random rotation for the object
    23.     transform.localEulerAngles.x = Random.Range(rotationRangeX.x, rotationRangeX.y);
    24.     transform.localEulerAngles.y = Random.Range(rotationRangeY.x, rotationRangeY.y);
    25.     transform.localEulerAngles.z = Random.Range(rotationRangeZ.x, rotationRangeZ.y);
    26.  
    27.     //If uniform, set the scale of every axis based on the X axis
    28.     if ( uniformScale == true )    scaleRangeY = scaleRangeZ = scaleRangeX;
    29.  
    30.     //Set a random scale for the object
    31.     transform.localScale.x = Random.Range(scaleRangeX.x, scaleRangeX.y);
    32.     transform.localScale.y = Random.Range(scaleRangeY.x, scaleRangeY.y);
    33.     transform.localScale.z = Random.Range(scaleRangeZ.x, scaleRangeZ.y);
    34.  
    35.     //Choose a random color from the list
    36.     var randomColor:int = Mathf.Floor(Random.Range(0, colorList.Length));
    37.  
    38.     //Set the color to all parts of the object
    39.     for ( var part in GetComponentsInChildren(Renderer))
    40.     {
    41.         part.renderer.material.color = colorList[randomColor];
    42.     }
    43. }
    And this is what it does:


    It may seem like something small, but it's all in the details, isn't it?
     
    Last edited: Jan 27, 2015
  12. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Managed to submit several updates yesterday including a small update for Astro Bouncer and a total port to C# for Space Ace made by Jordan Swapp. Space Ace now contains both JS & C# versions in the same package!
     
  13. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    did RFPS update get submitted?
     
  14. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Yes, I just submitted a bunch of updates including the LHToolkit to the store.

    I think it should be available on the store within several, if they don't reject it.

    BTW, how is it working out for you? Did you put locks in your levels. Is there a video we can enjoy? :D
     
    Last edited: Jan 29, 2015
  15. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    I decided to wait for the official update. I wanted to post some video or screenshots on RFPS forum.

    I am sure do so will generate a few sales for you )
     
  16. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    Thank you for the update.

    I just wanted to check if there is something wrong in the pdf documentation.

    In the RSPF intergration section it says to

    "Drag WeaponCamera.cs from LHAssets > CS_Assets > CS_Scripts > Misc to the Weapon Camera in the player."

    I was unable to find any file called weaponcamera.cs or LHWeaponCamera.cs. Is this step required or is this an oversight in the documentation?
     
  17. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Yes, you're right. This was in the 1.23 update which I sent before I contacted you last time.

    It was accepted within a couple of hours after submission ( must be some miracle ), and then I submitted the 1.24 update which has that weapon camera script. This one seems to be taking longer. It's been a couple of days, but it should be accepted soon. That's why I also avoided tweeting about it yet.

    It's been sort of a saga, but I appreciate your patience with me.

    BTW, I wanted to ask you if there are any specific kinds of locks/puzzles you would like to have in the package which could help you in your game?
     
  18. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    ok great. I will wait for the 1.24 update to get on the asset store.

    My suggestion for a new lock/puzzle would be for the addition of locked computer terminal. I see it in a lot of games. But the current locks and puzzles are already pretty good already.

    Thanks for the update.
     
  19. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Update 1.18 for Road Crossing Game has been submitted for review.
    - Added a shop where you can buy and unlock new characters to play as. The coins you collect during gameplay are stored and can be used to buy new cute animals.
    - You can toggle swipe controls for mobile devices. Swipe in a direction to move the player.
    - You can toggle the random move direction for the objects on a lane.
    - You can also set the width of each lane, so you can now have lanes of various widths.
    - Locked movement of player to the grid.

    Here's a cute preview:
     
  20. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    I'd like to share a game that was made using Road Crossing Game Template:

    It's called Loot Quest: Throne of Money and it's Thai Bui's first game in the App Store!

    Try it out here

     
  21. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's some gameplay from the upcoming Infinite Platform Hopper Game Template:

     
  22. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Infinite Platform Hopper Game Template has finally been accepted to the store. Took about 10 days, which seems to be the average time for reviews, if there are no hitches.

    Anyway, you can take a look at the store page here:
    https://www.assetstore.unity3d.com/en/#!/content/33508

    *holding breath for first sale*
     
  23. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's a little GIF from an upcoming ZigZag clone game template for the asset store.



    The main differences from the original are that the collectibles are scattered across the width of the path, which in turn is wider than the original, and the player rotates rather than snapping to an angle. And of course it has the getaway van theme to give it more meaning.
     
    Mister-D likes this.
  24. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Check out this video showing the process of creating a new character for Infinite Platform Hopper using Flash CS3:



    This also applies to most of my 2D games as they all use Flash CS3 for the graphics. Of course, you can use your favorite software to change the PNG spritesheet, but I love the ease of use Flash offers and the vector graphics.
     
  25. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's a gameplay video for the upcoming Zigzag Infinite Runner Game Template:


    Next up will be the update for Road Crossing Game, and maybe a C# conversion for Infinite Platform Hopper. Gotta end both of these in 3 days, yay!
     
  26. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
  27. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's a script that can run music in the game seamlessly, even when jumping from one scene to the next. Attach it to the music source, and set the tag in the inspector and in the music source. Like the screen below:



    You can have the music source in the initial scene and it will carry over to the other scenes, or you can place a music object in each scene and only one music source will be kept ( if it's older than 0 seconds ). I prefer to have a music object in each scene to make testing individual scenes easier.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. /// <summary>
    5. /// handles a global music source which carries over from scene to scene without resetting the music track.
    6. /// You can have this script attached to a music object and include that object in each scene, and the script will keep
    7. /// only the oldest music source in the scene.
    8. /// </summary>
    9. public class GlobalMusic:MonoBehaviour
    10. {
    11.     //The tag of the music source
    12.     public string musicTag = "Music";
    13.  
    14.     //The time this instance of the music source has been in the game
    15.     internal float instanceTime = 0;
    16.  
    17.     void  Awake()
    18.     {
    19.         //Find all the music objects in the scene
    20.         GameObject[] musicObjects = GameObject.FindGameObjectsWithTag(musicTag);
    21.      
    22.         //Keep only music objects older than 0 seconds
    23.         if ( musicObjects.Length > 1 )
    24.         {
    25.             foreach( var musicObject in musicObjects )
    26.             {
    27.                 if ( musicObject.GetComponent<GlobalMusic>().instanceTime <= 0 )    Destroy(gameObject);
    28.             }
    29.         }
    30.     }
    31.  
    32.     void  Start()
    33.     {
    34.         //Don't destroy this object when loading a new scene
    35.         DontDestroyOnLoad(transform.gameObject);
    36.     }
    37. }
     
    Last edited: Aug 23, 2015
    Kasaie and Mister-D like this.
  28. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Finally finished my Shooting Gallery Template, with the help of some awesome graphics from Kenney.nl. It's been submitted to the store so it should be accepted within a few days hopefully.

     
  29. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
  30. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's a script that can animate the colors of a sprite. I use it in backgrounds for my games, making it slowly turn from one color to the next as the game progresses. You can see it in action in the space backgrounds for Space Ace and Astro Bouncer, and you can also see it in the background for Hidden Object Game.

    CSharp:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. namespace HiddenObjectGame
    5. {
    6.     /// <summary>
    7.     /// This script animates a sprite with several colors over time. You can set a list of colors, and the speed at which they change.
    8.     /// </summary>
    9.     public class HOGAnimateColors:MonoBehaviour
    10.     {
    11.         //A list of the colors that will be animated
    12.         public Color[] colorList;
    13.        
    14.         //The index number of the current color in the list
    15.         public int colorIndex = 0;
    16.        
    17.         //How long the animation of the color change lasts, and a counter to track it
    18.         public float changeTime = 1;
    19.         public float changeTimeCount = 0;
    20.        
    21.         //How quickly the sprite animates from one color to another
    22.         public float changeSpeed = 1;
    23.        
    24.         //Is the animation paused?
    25.         public bool isPaused = false;
    26.        
    27.         //Is the animation looping?
    28.         public bool isLooping = true;
    29.  
    30.         /// <summary>
    31.         /// Start is only called once in the lifetime of the behaviour.
    32.         /// The difference between Awake and Start is that Start is only called if the script instance is enabled.
    33.         /// This allows you to delay any initialization code, until it is really needed.
    34.         /// Awake is always called before any Start functions.
    35.         /// This allows you to order initialization of scripts
    36.         /// </summary>
    37.         void Start()
    38.         {
    39.             //Apply the chosen color to the sprite
    40.             SetColor();
    41.         }
    42.        
    43.         // Update is called once per frame
    44.         void Update()
    45.         {
    46.             //If the animation isn't paused, animate it over time
    47.             if ( isPaused == false )
    48.             {
    49.                 if ( changeTime > 0 )
    50.                 {
    51.                     //Count down to the next color change
    52.                     if ( changeTimeCount > 0 )
    53.                     {
    54.                         changeTimeCount -= Time.deltaTime;
    55.                     }
    56.                     else
    57.                     {
    58.                         changeTimeCount = changeTime;
    59.                        
    60.                         //Switch to the next color
    61.                         if ( colorIndex < colorList.Length - 1 )
    62.                         {
    63.                             colorIndex++;
    64.                         }
    65.                         else
    66.                         {
    67.                             if ( isLooping == true )    colorIndex = 0;
    68.                         }
    69.                     }
    70.                 }
    71.                
    72.                 //If we have a sprite renderer, animated its color
    73.                 if ( GetComponent<SpriteRenderer>() )
    74.                 {
    75.                     GetComponent<SpriteRenderer>().color = Color.Lerp(GetComponent<SpriteRenderer>().color, colorList[colorIndex], changeSpeed * Time.deltaTime);
    76.                 }
    77.             }
    78.             else
    79.             {
    80.                 //Apply the chosen color to the sprite
    81.                 SetColor();
    82.             }
    83.         }
    84.  
    85.         /// <summary>
    86.         /// Applies the chosen color to the sprite based on the index from the list of colors
    87.         /// </summary>
    88.         void SetColor()
    89.         {
    90.             //If you have a sprite renderer component attached to this object, set its color
    91.             if ( GetComponent<SpriteRenderer>() )
    92.             {
    93.                 GetComponent<SpriteRenderer>().color = colorList[0];
    94.             }
    95.         }
    96.  
    97.         /// <summary>
    98.         /// Sets the pause state of the color animation
    99.         /// </summary>
    100.         /// <param name="pauseState">Pause state, true paused, false unpaused</param>
    101.         void Pause( bool pauseState )
    102.         {
    103.             isPaused = pauseState;
    104.         }
    105.  
    106.     }
    107. }
    108.  
    JS:
    Code (JavaScript):
    1. //This script animates a sprite with several colors over time. You can set a list of colors, and the speed at
    2. //which they change.
    3. #pragma strict
    4.  
    5. //A list of the colors that will be animated
    6. var colorList:Color[];
    7.  
    8. //The index number of the current color in the list
    9. var colorIndex:int = 0;
    10.  
    11. //How long the animation of the color change lasts, and a counter to track it
    12. var changeTime:float = 1;
    13. var changeTimeCount:float = 0;
    14.  
    15. //How quickly the sprite animates from one color to another
    16. var changeSpeed:float = 1;
    17.  
    18. //Is the animation paused?
    19. var isPaused:boolean = false;
    20.  
    21. //Is the animation looping?
    22. var isLooping:boolean = true;
    23.  
    24. function Start()
    25. {
    26.     //Apply the chosen color to the sprite
    27.     SetColor();
    28. }
    29.  
    30. function Update()
    31. {
    32.     //If the animation isn't paused, animate it over time
    33.     if ( isPaused == false )
    34.     {
    35.         if ( changeTime > 0 )
    36.         {
    37.             //Count down to the next color change
    38.             if ( changeTimeCount > 0 )
    39.             {
    40.                 changeTimeCount -= Time.deltaTime;
    41.             }
    42.             else
    43.             {
    44.                 changeTimeCount = changeTime;
    45.                
    46.                 //Switch to the next color
    47.                 if ( colorIndex < colorList.Length - 1 )
    48.                 {
    49.                     colorIndex++;
    50.                 }
    51.                 else
    52.                 {
    53.                     if ( isLooping == true )    colorIndex = 0;
    54.                 }
    55.             }
    56.         }
    57.        
    58.         //If we have a sprite renderer, animated its color
    59.         if ( GetComponent(SpriteRenderer) )
    60.         {
    61.             GetComponent(SpriteRenderer).color = Color.Lerp(GetComponent(SpriteRenderer).color, colorList[colorIndex], changeSpeed * Time.deltaTime);
    62.         }
    63.     }
    64.     else
    65.     {
    66.         //Apply the chosen color to the sprite
    67.         SetColor();
    68.     }
    69. }
    70.  
    71. //This function applies the chosen color to the sprite based on the index from the list of colors
    72. function SetColor()
    73. {
    74.     //If you have a sprite renderer component attached to this object, set its color
    75.     if ( GetComponent(SpriteRenderer) )
    76.     {
    77.         GetComponent(SpriteRenderer).color = colorList[0];
    78.     }
    79. }
    80.  
    81. // Set the pause state
    82. function Pause( pauseState:boolean )
    83. {
    84.     isPaused = pauseState;
    85. }
    86.  
    How to use: Just add it to any sprite, and set the colors you want to cycle through, as well as the change speed and change delay, like this:

     
  31. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
  32. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    I had a chance to update my AnimateColors script so now it also works with unity UI images.

    Here's the updated code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4.  
    5. /// <summary>
    6. /// This script animates a sprite, a text mesh, or a UI image with several colors over time. You can set a list of colors, and the speed at which they change.
    7. /// </summary>
    8. public class AnimateColors:MonoBehaviour
    9. {
    10.     //A list of the colors that will be animated
    11.     public Color[] colorList;
    12.  
    13.     //The index number of the current color in the list
    14.     public int colorIndex = 0;
    15.  
    16.     //How long the animation of the color change lasts, and a counter to track it
    17.     public float changeTime = 1;
    18.     public float changeTimeCount = 0;
    19.  
    20.     //How quickly the sprite animates from one color to another
    21.     public float changeSpeed = 1;
    22.  
    23.     //Is the animation paused?
    24.     public bool isPaused = false;
    25.  
    26.     //Is the animation looping?
    27.     public bool isLooping = true;
    28.  
    29.     //Should we start from a random color index
    30.     public bool randomColor = false;
    31.  
    32.     void Start()
    33.     {
    34.         //Apply the chosen color to the sprite or text mesh
    35.         SetColor();
    36.     }
    37.  
    38.     void Update()
    39.     {
    40.         //If the animation isn't paused, animate it over time
    41.         if ( isPaused == false )
    42.         {
    43.             if ( changeTime > 0 )
    44.             {
    45.                 //Count down to the next color change
    46.                 if ( changeTimeCount > 0 )
    47.                 {
    48.                     changeTimeCount -= Time.deltaTime;
    49.                 }
    50.                 else
    51.                 {
    52.                     changeTimeCount = changeTime;
    53.                  
    54.                     //Switch to the next color
    55.                     if ( colorIndex < colorList.Length - 1 )
    56.                     {
    57.                         colorIndex++;
    58.                     }
    59.                     else
    60.                     {
    61.                         if ( isLooping == true )    colorIndex = 0;
    62.                     }
    63.                 }
    64.             }
    65.          
    66.             //If we have a text mesh, animate its color
    67.             if ( GetComponent<TextMesh>() )
    68.             {
    69.                 GetComponent<TextMesh>().color = Color.Lerp(GetComponent<TextMesh>().color, colorList[colorIndex], changeSpeed * Time.deltaTime);
    70.             }
    71.          
    72.             //If we have a sprite renderer, animate its color
    73.             if ( GetComponent<SpriteRenderer>() )
    74.             {
    75.                 GetComponent<SpriteRenderer>().color = Color.Lerp(GetComponent<SpriteRenderer>().color, colorList[colorIndex], changeSpeed * Time.deltaTime);
    76.             }
    77.  
    78.             //If we have a UI image, animate its color
    79.             if ( GetComponent<Image>() )
    80.             {
    81.                 GetComponent<Image>().color = Color.Lerp(GetComponent<Image>().color, colorList[colorIndex], changeSpeed * Time.deltaTime);;
    82.             }
    83.         }
    84.         else
    85.         {
    86.             //Apply the chosen color to the sprite or text meshh
    87.             SetColor();
    88.         }
    89.     }
    90.  
    91.     /// <summary>
    92.     /// Applies the chosen color to the sprite based on the index from the list of colors
    93.     /// </summary>
    94.     void SetColor()
    95.     {
    96.         //A random color
    97.         int tempColor = 0;
    98.  
    99.         //Set the color randomly
    100.         if ( randomColor == true )    tempColor = Mathf.FloorToInt(Random.value * colorList.Length);
    101.  
    102.         //If you have a text mesh component attached to this object, set its color
    103.         if ( GetComponent<TextMesh>() )
    104.         {
    105.             GetComponent<TextMesh>().color = colorList[tempColor];
    106.         }
    107.      
    108.         //If you have a sprite renderer component attached to this object, set its color
    109.         if ( GetComponent<SpriteRenderer>() )
    110.         {
    111.             GetComponent<SpriteRenderer>().color = colorList[tempColor];
    112.         }
    113.  
    114.         // If you have a UI image attached to this object, set its color
    115.         if ( GetComponent<Image>() )
    116.         {
    117.             GetComponent<Image>().color = colorList[tempColor];
    118.         }
    119.     }
    120.  
    121.     /// <summary>
    122.     /// Sets the pause state of the color animation
    123.     /// </summary>
    124.     /// <param name="pauseState">Pause state, true paused, false unpaused</param>
    125.     void Pause( bool pauseState )
    126.     {
    127.         isPaused = pauseState;
    128.     }
    129. }
    130.  
    I used this updated code to animate the colors of the background UI in my upcoming Trivia Quiz Game Template:

     
  33. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Shooting Gallery Template is finally out, go get it!






    Features:
    - Game ready for release straight out of the box, just build and play!
    - Works on all platforms, PC, Mac, iOS, Android, etc
    - Supports multiple resolutions and aspect ratios, automatically.
    - Easily customizable with lots of options to control game difficulty.
    - If you need help with anything, contact me, I'll do my best :)
     
  34. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Today I was asked on twitter if Shooting Gallery can be built and run on iOS 64 (ILL2CP). Since it's derived from my previous template Gunslinger I assumed it should work just fine.

    Well, it worked!

    Here's a video showing the game build and deploy on an iPhone, straight out of the box:


    ...and the video is flipped, hilarious :D
     
    Last edited: Sep 15, 2015
  35. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Working on my next game template, here's a Flying Kawaii Robot Blaster:



    Will post some gameplay later.
     
    theANMATOR2b likes this.
  36. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Today I had a particularly nasty system crash, which almost cost me a couple hours worth of work on one of my game scenes. The scene was seemingly lost, when opened it had nothing inside, no prefabs, no cameras or lights. Nothing.

    Looking through the net I found this awesome page with a really nice way of restoring your lost scene. Here's how to do it:
    - In your project folder there should be a folder named Temp ( Don't open and close your Unity instance so you don't lose that temp folder ).
    - In the temp folder there is a file called EditModeScene.
    - Rename this file to scene.unity and add it to your project folder.
    - Now it should open with all your lost stuff intact!

    Here's the website I got this tip from. Has some more tips and tricks:
    http://unityready.com/restore-scene-crashed-unity3d-instance/
     
    theANMATOR2b and Aiursrage2k like this.
  37. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Thats a nice tip. I have lost a few hours every time it crashes (and quite frankly you might change something forget what it was after the crash).
     
  38. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Yeah, it's a real time saver. I already lost quite a few scenes in the past, and it's always annoying to try to build the scene from memory.
     
  39. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    After an arduous submission process, Trivia Quiz Game Template is finally out. Took at least a couple of weeks, some tiny oversights (Unity3D should be named Unity in the documentation), but it's live now.

    So go and take a look at it here:
    https://www.assetstore.unity3d.com/en/#!/content/45521
     
  40. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
  41. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Today I got a chance to submit the first update for Trivia Quiz Game.

    This one adds keyboard and gamepad support, which was a really elegant and simple piece of code IMO; When a "Horizontal"/"Vertical" input is detected, keyboard controls take effect and if none of the answers are selected, the first of them gets highlighted. When you move the mouse, click it, or tap the game area, keyboard controls are lost again. Very simple and practical.

    The other thing I added was the ability to set less than the maximum allowed number of answers per questions. So now you can have questions with 4,3, or 2 answers in the same trivia level. You have to set up the buttons at the start and then any extra answers are hidden in-game.

    Next I think I'll try to see how to allow adding questions in bulk, maybe XML or something similar.
     
  42. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Making some good progress on my next template, should be done and submitted within a couple of days.



    The gameplay changed a bit from when I first started it, so no more charging shot and no more pushing enemies back. Now you have to shoot the enemy with a bullet of the same color to kill it. Makes things much more interesting IMO.
     
  43. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Forest Defense is finally ready to show!



    If anyone has feedback or comments about the game, I would love it!
     
  44. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Today I had an interesting request from a buyer, which I thought would be a really nice addition to my game template. The buyer wanted a way to display cut scenes in between enemy waves in Space Ace Game. A few hours later and I had a working system that can do just that!

    My main problem was that the Pause() function I use sets Time.TimeScale to 0, which essentially stops everything from moving. I had to find another way to display an animated cutscene. After a bit of googling I found this awesome piece of code:

    Time.realtimeSinceStartup

    (source: http://forum.unity3d.com/threads/playing-animation-w-time-timescale-0.88579/)

    This essentially counts the actual time since the game began, regardless of what time scale is set to. Awesome, isn't it?

    You can expect the new update for Space Ace to be live in the next few days.
     
  45. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Been working hard on the next update for Trivia Quiz Game, adding the option to have more than one player defined, which opens up the game for more game modes such as 2-4 player hotseat. Also organized the components better with hover-comments, plus some bug fixing.

    Check out the new update here:
     
  46. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Right now I'm going through all the packages updating them so they work nicely with Unity 5.3. The main change from previous versions is that instead of Application.LoadLevel(), and Application.LoadedLevelName we should use SceneManager.LoadScene(), and SceneManager.GetActiveScene().name.

    If you start a project now with Unity 5.3 you'll get a warning stating that Application.LoadLevel() is obsolete. The game will still work fine, but it's not nice to have all these warnings popping up in your project.

    Here's an example of how the code should be changed:

    Older code before Unity 5.3:
    Code (CSharp):
    1. public void LoadALevel( string levelName )
    2. {
    3.     Application.LoadLevel(levelName);
    4. }
    5.  
    6. public void RestartLevel()
    7. {
    8.     Application.LoadLevel(Application.LoadedLevelName);
    9. }
    New code after Unity 5.3:
    Code (CSharp):
    1. using UnityEngine.SceneManagement;
    2.  
    3. public void LoadALevel( string levelName )
    4. {
    5.     SceneManager.LoadScene(levelName);
    6. }
    7.  
    8. public void RestartLevel()
    9. {
    10.     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    11. }
    Notice how in the new code we also added using UnityEngine.SceneManagement; at the start of the script to allow the use of the new code bits.

    In my case, I want to update all the games so that they don't have warnings in Unity 5.3, but at the same time I want to allow users of older versions to keep the code the same way it was ( ex: Unity 4 doesn't have SceneManager at all, so they can't use the new code ). This will require the use of code conditionals like this:

    Code (CSharp):
    1. #if using UNITY_5_3
    2. using UnityEngine.SceneManagement;
    3. #endif
    4.  
    5. public void LoadALevel( string levelName )
    6. {
    7.     #using UNITY_5_3
    8.     Application.LoadLevel(levelName);
    9.     #else
    10.     SceneManager.LoadScene(levelName);
    11.     #endif
    12. }

    Anyway, expect a round of updates for all my templates in the next week or so.
     
  47. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    The updates for Unity 5.3 are going slowly, but surely. I'm taking the opportunity to add in UnityAds support for the packages too. Hoping to update the entire portfolio before year end.

    Also, if anyone downloaded the latest Trivia Quiz Game 1.24 (12.12.2015), you may have had an error trying to build for mobile ( iOS, Android, etc). The error happens because Unity *does not* support video playback on mobile devices. I did not know that before adding the video questions to the package, so now I'm sending a new update (1.26) to fix that issue. You'll still be able to use video questions in Unity 4 pro and Unity 5, but of course not on mobile.
     
  48. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Had an inexplicable burst of productivity in the past couple of weeks, so I'll be releasing two new games in the next few days.

    Here are the gameplay vids:



     
  49. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Here's one that's dear to my heart; It's a remake of one of my earlier Flash game templates, made from scratch with Unity while trying to keep the charm of the animations and sound effects intact.



    The idea is simple: use the hammer to smash the moles as they emerge from their holes. You get extra points for hitting as many moles as you can before they hide again. When you get enough points you move on to the next level and earn a few more seconds on the clock. You can try it out here:
    http://puppeteerinteractive.com/Webplayers/WAM

    And it's also available to buy on the Unity Asset Store, you can get it here:
    https://www.assetstore.unity3d.com/#!/content/61880
     
  50. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Testing out my hand-made ( or tongue-made ) sound effect for the quick mole: