Unity Ads

Wow. That was easier than I expected. I signed up in the services section of Unity, turned on “test mode”. Then created a button and added the following 2 scripts to said button and it worked like a charm 🙂

This code shows the rewarded ad types. Video ads that the player chooses to watch and will be rewarded if they are seen to the end.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using UnityEngine;
using UnityEngine.Advertisements;
 
public class UnityAdsInitializer : MonoBehaviour {
    [SerializeField]
    private string
        androidGameId = "Number Found In Services->Settings->Advanced",
        iosGameId = "Number Found In Services->Settings->Advanced";
 
    [SerializeField]
    private bool testMode;
 
    void Start() {
        string gameId = null;
 
#if UNITY_ANDROID
        gameId = androidGameId;
#elif UNITY_IOS
        gameId = iosGameId;
#endif
 
        if (Advertisement.isSupported && !Advertisement.isInitialized) {
            Advertisement.Initialize(gameId, testMode);
        }
    }
}

Continue reading →

Pause Screen

I’ve been working on the in game pause screen for a bit now. I really wanted to let the user see the island as a whole plus have the ability generate new islands (start a new game) while in the game mode. It’s actually turned out pretty nice 🙂

Pause screen

The “only” things left are to implement are:

  1. A game over screen
    • Convert points into spendable credits
    • Log a high score online
  2. Front end menus
    • Character/Island select
    • Possible shop
    • Facebook integration?
    • etc
  3. Models for characters and island types (plus super secret bonus level)
    • Loads of modelling in Blender coming up… great :-/

There will probably be loads of other things I haven’t even thought of yet.

Arg… the loop (part 2)

I didn’t realise how much effort looping the map was going to be. I’ve still got visible tearing and shadow issues at the edges and now an – albeit minor – audio problem. Unity comes with a great method for playing audio at the correct volume based on the distance between the listener and the audio source. It’s built in! But all that goes out of the window with a looped level. ugh. For example; If the player (listener) is close to one edge of the map and an explosion happens at the opposite end of the map the built in method won’t play the sound (or play it very quietly) as the player and explosion appear – to Unity – to be far apart. Only they aren’t. In the looped view they are side by side.

To handle this I’ve had to write my own simple audio controller to adjust sounds that would be affected by the loop. Essentially any sound that needs it’s volume adjusted based on the perceived (not actual) distance from the player.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public void GroundExplosion(Vector3 position) {
    //Select a random explosion sound from an array of sound clips
    AudioClip boom = groundExplosions[Random.Range(0, groundExplosions.Length)];
    audioPlayer.PlayOneShot(boom, VolumeToPlay(position));
}
 
private float VolumeToPlay(Vector3 position) {
    //Get the distance on Z between the objects
    float distance = Mathf.Abs(player.transform.position.z - position.z);
 
    //Is the distance greater than the half length of the map?
    if (distance > (map.length / 2)) {
 
        //Remove the excess (i.e. get the excess above the half and remove from the Distance)
        distance = Mathf.Abs(distance - map.length);
    }
         
    //Return a value (Between 0 and 1) based on the max distance, closest distance, current distance)
    return Mathf.InverseLerp(map.length / 2, 0, distance);
}

My audio controller is handling quite a number of different sounds and I only need to worry about distance on the Z axis, but hopefully this is enough to show how it’s managing it. I wonder what “the loop” will throw at me next. Cheers, J

Blender

It’s been a while since my last update. Things on the game front have been moving along fairly nicely although building the models is rather more taxing than I thought it would be. My relationship with Blender is a bit of a love/hate thing. SO much seems counter intuitive but it’s clearly such a powerful tool that I’m going to do my best to move past my frustrations.

Game Progress

Obviously it’s still early days regarding the models so don’t be too harsh 😉 Follow the link below to see a rather large (30 Mb) gif of the progress so far.

Continue reading →