Tile-Based Movement Using iTween

Shiba’s Adventure is the new roguelike RPG game that we developed in iOS and Android that using tile-based movement. The tile-based movement is very easy to implement and today we would like to share with you how do we achieve the movement like this:

The secret recipe that we use is iTween! (Oopsss…it’s no longer secret now). iTween is lightning fast, lightweight and FREE animation system that makes implementing animation easier than ever. To implement tile-based movement with iTween, you just need to use MoveTo(GameObject target, Hashtable args)

// Assume the distance between tiles is 1f
Vector3 targetPosition = transfrom.position + new Vector(1f, 0f, 0f);
iTween.MoveTo(gameObject, iTween.Hash(
    "position", targetPosition,
    "time", 0.2f,
));

The code above allow you to move your game object from tile to tile. However, if you wish to make “jumping” effect thru the tiles, you can can use path​.

// Assume the distance between tiles is 1f
Vector3 targetPosition = transfrom.position + new Vector(1f, 0f, 0f);
Vector3 middlePoint = (transfrom.position + targetPosition) / 2;
iTween.MoveTo(gameObject, iTween.Hash(
    "path", new[] { middlePoint, targetPosition },
    "time", 0.2f,
));

Now you will have a “jumping” effect when moving across the tiles.

iTween is really a great tools that simplify implementing animation in Unity3D. You can download iTween from Asset Store and check out the documentation.  

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: