This short guide will show you how to make the circle animation below. It’s actually quite simple.

alt text

First you will need to create an image to use for your animation. If you’re to lazy you can just use the one I made. Download Image. Save it into the Assets folder of your Unity project.

We are going to make the background image first. Create a new UI Image object (Gameobject > UI > Image) call it “Loading Circle”. On the Image Component set the Source Image the one you created or downloaded and give it a colour you fancy.

Once you have done that you will need to duplicate it (Right Click > Duplicate). Rename the duplicated gameobject to “Progress”, make it a child of the “Loading Circle” gameobject and change its anchor points to stretch on both the X & Y axis. Again change it’s colour to something you want.

On the “Progress” gameobject change the Image Type on the Image Component to “Filled”, set the Fill Amount as 0.1, and ensure Fill Method is “Radial 360”.

All you need to do now is assign the script below to the “Progress” gameobject and you should have a working animation.

The Code

using UnityEngine;

public class LoadingCircle : MonoBehaviour
{
    private RectTransform rectComponent;
    private float rotateSpeed = 200f;

    private void Start()
    {
        rectComponent = GetComponent<RectTransform>();
    }

    private void Update()
    {
        rectComponent.Rotate(0f, 0f, rotateSpeed * Time.deltaTime);
    }
}

This is a sneak peak on the hacking game that we are currently working on called “System Subversion”. Everything you see is very early in the build process so will more that likely change in the final game.

The plan is to have it semi-realistic with the game’s core element being the terminal window. To make it more player friendly, most commands will always have a way for the player to just click a button and do the same thing. This gif below shows opening the storage window (where all the files the player has are stored are) both through typing in the terminal and by just clicking icons.

alt text

This is just a nice short and simple script that I sometimes use to make the camera in Unity smoothly follow an object. Just add this script to a orthographic camera and select a target and follow speed in the inspector.

The Code

using UnityEngine;

public class CameraFollow2D : MonoBehaviour
{
    public float FollowSpeed = 2f;
    public Transform Target;

    private void Update()
    {
        Vector3 newPosition = Target.position;
        newPosition.z = -10;
        transform.position = Vector3.Slerp(transform.position, newPosition, FollowSpeed * Time.deltaTime);
    }
}