Month: May 2015

  • Demonfall Week 6 Progress

    Pause menu appears when you press the pause button mid game. Animations added include the guy, lava and demon hand. Also 3 of the 5 demons are animated as well; featured is the demon spirit. What’s next: I’m starting to think I set up the buttons wrong. They might be listening for mouse clicks instead…

  • Reusable Move Function in Unity

    Similar to the Fade Function, here’s the Move one: public IEnumerator move(GameObject obj,Vector2 targetPos, float speed = 1){         Vector2 startingPos = obj.transform.position;         while(startingPos.x != targetPos.x || startingPos.y != targetPos.y){             Vector2 curPos = obj.transform.position;             if(curPos == targetPos){                 yield break;                 }             obj.transform.position = Vector2.MoveTowards(curPos, targetPos, speed*Time.deltaTime);             print (“moving “+curPos +” – “+targetPos );             yield return null;         }     } This function assumes you’re moving a game object from it’s current position to another. It’s parameters are the GameObject, the position it wants to move to and a speed that’s set to 1 by…

  • Reusable Fade Function for Unity

    This is the function I use: public IEnumerator fade(GameObject obj,float fadeSpeed = -0.1f){         for (float f = obj.GetComponent<Renderer>().material.color.a; f <= 1 && f>=0; f += fadeSpeed) {             Color c = obj.GetComponent<Renderer>().material.color;             c.a = c.a + fadeSpeed;             if(c.a <0){                 c.a = 0;             }             if(c.a >1){                 c.a = 1;             }             obj.GetComponent<Renderer>().material.color = c;             yield return null;         }     } This function has 2 parameters: 1) the game object that’s to be faded and 2) the fade amount. By default it’s -0.1f which you can change. To use this function just use: StartCoroutine(fade(myGameObject)); StartCoroutine(fade(myGameObject,0.1f)); The…

  • Fielded Content Types in Drupal

    Content types are like a custom type of page that also be used to sort other pages. In this example we’re making a destination content type and then allowing another page to select what destination that page belongs to. To make a content type, go to ‘Structure/Content Types’ and then the ‘Add content type’ button.…

  • Demonfall Week 5 Progress

    I’m happy to say I got all the demon’s attacks working :) This includes the warnings, gradually stronger attacks and how it affects the player if they get hit. I’ve changed one of the demon’s effects from the original game because I felt it didn’t fit in with the others and feel much happier with…

  • Making a local Drupal site

    I use MAMP to manage different sites. Also download Canvas which provides the installation files. Unzip the Canvas file and put the files somewhere on your computer. Open MAMP, go to the ‘Hosts’ tab and click the + button on the bottom left. Give a server name eg. canvas.localtest. Click the folder icon to the right of ‘Document…

  • Animating in Unity

    This example is to make a constant animation loop endlessly (say a shining sun animation). The first thing you need is a spritesheet which is basically all the animation frames in 1 image. I usually do this in Flash. When you’re done, drag the spritesheet image into Unity. In the Inspector change ‘Sprite Mode’ to…

  • Demonfall Week 4 Progress

    Decided to leave the tutorial levels till later and do something more fun – adding the demon levels. The first demon’s lightning attack is fully functional. Lightning randomly appears on the screen and it’s size,number and frequency gradually increase as your score increases. Touching it will shock you causing you to be unable to move…

  • Making a singleton in Unity

    What is a singleton? Basically, it’s code that can be used by everything else. This means you can share code between scenes in Unity. I usually use this to make sharable GUI styles. This is the basic set up: public class singleton : MonoBehaviour {     private static singleton instance;     void Awake()     {         instance = this;     } Now you can specify variables and functions here that can…

  • Using Icon Fonts in Unity

    In this example I’m using Font Awesome. First you download it and then drag the .ttf font file into your Resources folder. Now, there are 2 ways to add text: in the UI and in code. Let’s go through both. Adding icons in the UI Say you had a button in the hierarchy with a…