Author Archive

Unity: my object’s physics doesn’t work ? why ?


I stumbled onto this issue and solved it.

So, I had a 3D object with a collider on it and it was not acting as a collider.

I had a script on that object which animates its movement through transform.lerp in a update funtion

Why was the physics not working ?

It is because if you update the object’s position on each frame though functions like transform.lerp, it bypasses the unity’s physics calculations on that object (even the child objects attached to it) and hence no physics works on it. So, I ended up using a character controller on it.


How to split apk and generate obb for google play store using Unity 3.x and Windows. (Also works on Mac, haven’t tested it)

Hi guys,

I saw a lot of posts and I could not find this tutorial anywhere. So, I am posting it here for others. Scroll to the end to find my scripts.

I actually started with this great tutorial written for unity 4

Here are the steps for unity 3.x

0) Add the GoogleOBBDownloader package from AssetStore. Now go to GooglePlayDownloader.cs and change the PUBLIC_KEY in it to match yours

1) Create a new scene called “Scene 0”. Add a empty game object and attach the script “DownloadObbExample.cs”

2) go to build settings and select only “Scene 0” and build the apk file from it.

Note: Make sure you fill out public key, keystore, version and package name in player settings.

3) Now add the script BuildStreamedSceneAssetBundle.cs in Assets/Editor

4) Edit the script to add all the levels you want to package

5) You wil see the option BuildWebplayerStreamedLevels in Build menu of unity. Use that to build asset package which is a .unity3D file

Note: asset packages are not distributable. Hence, you have to edit this line in the BuildStreamedSceneAssetBundle.cs for each platform and rebuild the asset package

BuildPipeline.BuildStreamedSceneAssetBundle(levels, “Levels-AssetBundle.unity3d”, BuildTarget.Android);
//for pc and mac use BuildTarget.WebPlayer and for Iphone use BuildTarget.Iphone

6) Rename your asset bundle as ” main.versionNumber.packageName.obb” (versionNumber and packageName should match the ones in step 2)

Note: if you have multiple .unity3D files you can zip them together and then rename that zip file as above

7) Upload them both on google play and your game should load smoothly.

Here is my code from “DownloadObbExample.cs”
public class DownloadObbExample : MonoBehaviour
private string expPath;
private string logtxt;
private bool alreadyLogged = false;
private string nextScene= “StartingLevel”;
private bool downloadStarted;
private string progress=” “;
void log( string t )
logtxt += t + “\n”;
void OnGUI()
GUI.Label(new Rect(10, 10, Screen.width-10, Screen.height-10),
logtxt+” “+progress);
if (!GooglePlayDownloader.RunningOnAndroid())
GUI.Label(new Rect(10, 10, Screen.width-10, 20), “Use GooglePlayDownloader only on Android device!”);
expPath = GooglePlayDownloader.GetExpansionFilePath();
if (expPath == null)
log (“External storage is not available! “);
string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath);
if( alreadyLogged == false )
alreadyLogged = true;
log( “expPath = ” + expPath );
log( “Main = ” + mainPath );
if (mainPath != null)
if (mainPath == null)
GUI.Label(new Rect(Screen.width-600,
Screen.height-230, 430, 60),
“The game needs to download 200MB of game content. It’s recommanded to use WIFI connexion.”);
if (GUI.Button(new Rect(Screen.width-500, Screen.height-170, 250, 60), “Start Download !”))
protected IEnumerator loadLevel()
string mainPath;
yield return new WaitForSeconds(0.5f);
mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
log(“waiting mainPath “+mainPath);
}while( mainPath == null);
if( downloadStarted == false )
downloadStarted = true;
string uri = “file://” + mainPath;
log(“downloading ” + uri);
WWW www = WWW.LoadFromCacheOrDownload(uri , 0);
while( !www.isDone )
progress = Time.time+” “+ http://www.progress;
yield return null;
AssetBundle ab=www.assetBundle;
if (www.error != null)
log (“wwww error ” + http://www.error);
log(” ab is null “);
log(Time.time+” loaded ab”);
here is my code for BuildStreamedSceneAssetBundle.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
public class BuildStreamedSceneAssetBundle : MonoBehaviour {
public static void MyBuild(){
string[] levels  = {“Assets/Scenes/level01.unity”,
BuildPipeline.BuildStreamedSceneAssetBundle( levels,
“Levels-AssetBundle.unity3d”, BuildTarget.Android);

view bounding boxes around sprites

Just found a useful thing in cocos 2D.

If you wanna see the bounding box around sprites..

go to the ccConfig.h file (it’s in libs –> Cocos2d) and towards the bottom there’s two options CC_SPRITE_DEBUG_DRAW and CC_SPRITEBATCHNODE_DEBUG_DRAW. Change the 0’s on both of those to 1’s and then a white box will show up around every sprite. If you are creating CGRect’s around your sprites for collision detection then you could add the code below to your .m file with the sprites you want to view the boxes on

It is very useful for me for debugging..


The rule I found today.

When I was doing my 3D graphics project on ray tracing today, I realized something which is worth sharing

smartkiran rule:

A golden rule for any prorgamming task I found is that

“Even though you are not sure how to do it, just try to write some crap which atleast works without errors. So that you will atleast have something to change into a perfect solution. ”

analogy.. “without a basement how can you construct a house”

What is Thralled ?

Oh yeah ! I said I am working for a demo of Thralled. What is it ?

It is a ipad game for the advanced games class starting next semester. I kinda promised Thralled team that I will be making a 5-minute demo game for them by april 26th, when they have to deliver their final round of pitch. I have been the only programmer working on it. Now once again, I realize the value of a team.

smartkiran rule friends.. ‘Always work in a team. It helps you grow and realize your mistakes’. ‘One team project is better than 4 individual projects’

You can read about thralled here..

did you see the crew page in the above website. You can see my name !! 🙂 🙂

This is the first ever time where I have my professional intro on a website.

Finals Week – Scary week

The Finals week has begun.

All the deadlines are near by. Am I tensed? No, I am more worried than tensed.

Worried because of my biggggg to-do list

1) Complete 3D graphics Project

2) Complete mobile games project

3) Complete the demo for Thralled

4) Complete the tasks of job at ISI

5) Prepare for the 570 exam

All the above are very intriguing and intensive, consuming lot of time.

Back to blogging

Hi friends,

Its been a while since my last post. How are you all ?

My first semester was pretty good. Though I still can’t believe I got an A- in Game Design Workshop. Am happy that my current GPA stands at 3.9.

It was time for the next semester and I have chosen the courses very carefully this time.

1)Advanced Analysis of Algorithms    under Prof. Shamsian

2)Advanced Mobile Devices and Game Consoles  under Prof. Mike Zyda (No offense, he is one of the best)

3)3 D Graphics and Rendering  under Prof. saty

I am doing a mobile game as part of my mobile games class. It is FLOW MASTER.

All the info stuff regarding what that is can be seen at my website here. I am not gonna say that again


I love my team at Flow Master. But their programming skills are not that great compared to my team mates at Game Engine class the previous semester.


It is in fact surprising though, in the Game Engine class though I was lead I took suggestions from other team mates as I was the inexperienced guy. But, in mobile games class I have been giving suggestions to my team mates. Now, I seem a little more experienced than them. To be honest, I am not a experienced guy.  My hunger and enthusiasm towards new things makes me look like that.



%d bloggers like this: