Wednesday, April 1, 2015

How to integrate Admob into Unity Android Build

I am using MacOS Mavericks, Unity 5 Personal Edition and GooglePlayService Rev 23 and Eclipse Juno.
For integrating Admob into Unity iOS see this post.

Download Unity plugin from here:

https://github.com/googleads/googleads-mobile-plugins/releases

At time of writing the latest  is Google Mobile Ads Unity Plugin v2.2

Download it and import to unity after creating a Plugins folder in Assets.

Insert the necessary code to call your Admob Banner and Interstitial ads. For me I wrote a custom script called AdsController.cs:

using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
using System;  // For EventArgs

public class AdsController : MonoBehaviour {
   
    InterstitialAd interstitial;
    BannerView bannerView;

    void Start () {

        
//------ Banner Ad -------
        // Create a 320x50 banner at the top of the screen.
        // Put your Admob banner ad id here
        bannerView = new BannerView(
            "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx"AdSize.SmartBannerAdPosition.Top);
        // Create ad request
        AdRequest request = new AdRequest.Builder().Build();
        // Load the banner with the request.
        bannerView.LoadAd(request);
        
        bannerView.Show();

        
//---- Interstitial Ad -----
        // Initialize an InterstitialAd.
        // Put your admob interstitial ad id here:
        interstitial = new InterstitialAd("
ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");

        //Add callback for when ad is loaded
        interstitial.AdLoaded += HandleAdLoaded;

        // Create an ad request.
        AdRequest requestInterstitial = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(requestInterstitial);
    }
    
   

    public void HandleAdLoaded(object senderEventArgs args) {
        
        interstitial.Show ();
    }

  
    void OnDestroy(){
        if (interstitial!=null) {
            interstitial.AdLoaded -= HandleAdLoaded;
            interstitial.Destroy ();
        }
        if(bannerView!=null){
            bannerView.Destroy ();
        }
    }

}


Put the script above in Game Over scene, or, Level Cleared scene. So that when the scene loads, the banner and interstitial ads get called and shown at the same time.

Open Eclipse Android SDK Manager and download the latest Google Play Service SDK:


Then copy and paste the google-play-services_lib folder located at ANDROID_SDK_LOCATION/extras/google/google_play_services/libproject,  into the Plugins/Android folder of your project as shown circled in red below:



Then modify the AndroidManifest.xml file shown above circled in green as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" 
package="com.site.myappnameandroid:versionName="1.0android:versionCode="1">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" 
  android:xlargeScreens="trueandroid:anyDensity="true" />
  
  <!-- Google Mobile Ads Permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
    <!-- meta-data tag for Google Play services -->
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
    <activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:label="@string/app_name" 
    android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
    <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <meta-data android:name="android.app.lib_name" android:value="unity" />
    </activity>
    <activity android:name="com.unity3d.player.VideoPlayer" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
    </activity>
   
  </application>
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
</manifest>


Make sure you do not add the Ads Activity because it is already included in the GooglePlayService Lib manifest file and will be merged with AndroidManifest.xml above during build.

Next, build the Unity Android .apk file  with the player setttings shown here (on right side of screen):



Transfer the apk to your android phone/tablet and run.



Thursday, March 26, 2015

Power Ups

Power Ups can be:

1. Coin type
2. Kill all enemies
3. Invincibility
4. Strike
5. Powerup Magnet
6. Set Checkpoint
7. Next Checkpoint
8. Restart Checkpoint

Tuesday, March 24, 2015

Game Mechanics, Dynamics and Aesthetics

What is the difference between Game Mechanics,  Game Dynamics and Game Aesthetics?

Game Mechanics are the rules of the game.

Game Dynamics is the direction or resulting effect of the Game Mechanics.

Game Aesthetics is the experience of the player based on the Game Dynamics.

For example,  certain game mechanics might reward a player with power ups including shields.
The resulting dynamics is that the player is invincible and can defeat enemies easily (positive feedback loop). The aesthtics is the feeling of satisfaction and accomplishment on defeating the enemies.

Certain schools of thought in Game Design advocate starting with Aesthetics then work backwards to Dynamics then back to Mechanics. For example, first ask yourself, what sort of Player experience/feeling do I want the player to have?  Is it accomplishment, anger, fear, greed, friendliness?  Then find out what sort of Dynamics can bring that feeling/experience? Then determine what sort of mechanics can bring about those Dynamics.

So, designing game is designing experience.

A formal definition is:


Mechanics describes the particular components of the game, at the level of data representation and algorithms.
Dynamics describes the run-time behavior of the mechanics acting on player inputs and each othersí outputs over time.
Aesthetics describes the desirable emotional responses evoked in the player, when she interacts with the game system. 

MDA : A Formal Approach to Game Design and Game Research

Monday, March 23, 2015

How to Design Better Games than your Competitors'

Study your competitors' games.

Jot down what you like and what annoys you.

Design your game based on your competitors but leave out the annoying and improve on the parts that you like.

Saturday, March 21, 2015

Quick and Dirty Prototyping

Here's a good article on Quick and Dirty Prototyping

Basically, use placeholders to represent artwork. Get the playtesting done early and repeatedly.
Don't put in high quality graphics until the very end - to avoid Asset Guilt.




Graphic Assets

Where to get graphic assets? Below are some sources.

1.  Super Pixel Time

2. Open Game Art Tutorial

3. Making Pixel Art Tutorial

4. Graphic River

5. Construct2 Art Shop

6. Graphic Buffet

7. Open Game Art

8. Atelier Store


Game Themes and Styles

What is the difference between Themes and Styles?

Themes:

   1. Fantasy

   2. Seasonal

   3. Racing

   4. Zombie


Styles:

   1. Minimal

   2. Pixel

   3. 2D

   4. 3D

   5. Isometric

   6. Retro

   7. Arcade

   8. Realistic