Sunday, 1 May 2016

Unity 2D Game Prototype inspired by Soundrop (Unity Remote 4 on iPad Mini)

The concept of Soundrop game is quite interesting: you draw lines on the device and when the falling ball bounces off the line, it will make a short tune/noise. By creating a few more balls and lines makes the whole thing quite interesting.

Inspired by the game, I created a simple prototype. Took me a long time to get the interface working. Was have problem getting the positions of lines from LineRenderer and have to use a "List" to store the start and ending position of each line so that it can be modified later during dragging. Can now drag on the end points of each line to adjust the length and direction of each line. Still have problem with using double tap to remove the line. As a workaround, by reducing the length to very small amount, can achieve the same result.


Currently uses audio.pitch to adjust the sound depending on the time between current and previous collisions. I think if use more WAV files for different delay might get better result.

Still looks a bit rough when running under Unity Remote 4 on iPad Mini, compared with the much sharper and clearer screen on the Mac (about 43 second of the video).

Sunday, 24 April 2016

Unity 3D Traffic Game Prototype

Donuts games has a 2D traffic rush game before, and recently noticed it now has a 3D version called "Traffic Rush 2" as well.

Created a 3D traffic game prototype based on the game and again, with demo video running on iPad Mini through Unity Remote 4.

Took me a while to get the swipe control working correctly, and as the blocks/cars should only move in one specific direction, the transformed position after swipe need some adjustment to make sure only the x/z element of position changed.

Player taps on block(car) to stop its movement, swipe to resume movement or make it move faster. Blocks will be destroyed if reached border. When collides with another block, stopped movement and shows particle effect.


Further improvements:
1) After swipe, increase the speed
2) Show trailing smoke/dust after block
3) Add surrounding buildings and lines on the road
4) reduce the distance between where the blocks were instantiated to make it more challenging
5) After a block/car been stopped, start a counter so after X seconds later it flashes the light and starts moving automatically


Friday, 22 April 2016

2D Swing Game Prototype

Even though it's a bit old now, the "Mr.AahH!!" game by Japanese company Ponos has always been one of my favourite games. It's very simple and quite addictive. You just have to tap on the screen when the little guy is swinging on the rope, and he will release the rope. If he successfully landed on the other platform then you passed that level, and the closer you landed towards the centre of the platform, you get more points. 

The fun part is, the wind and gravity changes every level, so you can't always tap at the same time and have to adjust accordingly.


Quite happy that I finally got a working prototype of 2D swinging game today, using DistanceJoint2D. The line was drawn using Line Renderer, just have to change one of the end point in LateUpdate while it swings around.

Thursday, 21 April 2016

Shadowmatic - amazing shadow game

The award winning Shadowmatic (by TRIADA Studio) is a really amazing game.

The background, visual, the interface design, the music, the way the view angle moves when you move your phone, ...etc, all very professionally done.



Have a play with shadow today using a spotlight plus background. With just a few blocks and spheres, it still took me a while to create an ugly camera... Imagine how much time is required to create each and every complicate 3D model to form all the different shapes!
 

Wednesday, 20 April 2016

2D Game Prototype - Combining Shadow Test with Touch Movement

This is a quick prototype in Unity, by combining previous Shadow Test (#2) project, with "drag and drop in unity" tutorial from Aarlangdi Production.

Basically similar to Shadow game (buildbox games https://www.youtube.com/watch?v=H7EqQ3VBdOY), you move player cube by touch/drag, if collided with any moving enemy cubes, player died and played particle effect.

As this is using Unity Remote 4 on iPad Mini, the resolution is not as good as the one from Shadow Test (#2) project, as that video was captured directly on laptop screen using CamStudio.

Another thing for further improvement is, in the Shadow game, you can tap on anywhere on the screen and move around, the player object will move accordingly. However in my prototype, have you drag on the player object as the "OnMouseDown/OnMouseDrag" event listening code is on that object. Just need to add a transparent plane (MeshRenderer disabled) on top and move the "OnMouseDown/OnMouseDrag" to the plane.

Another helpful site

Found quite a lot of helpful information from Aarlangdi Production blog.

Tuesday, 19 April 2016

2D Seesaw Game Prototype running on iPad Mini (Unity Remote 4)

After watching the Unity tutorial on Hinge Joint 2D, spent some time this afternoon and created this 2D Seesaw Game Prototype using hinge joints.


Spent a lot of time adjusting the angle, position, friction of material, ball physics, ...etc.

Currently it shows message about whether the color of the ball matches the color of the hat, but only on the console. Haven't got time to display GUI/UI Text or score as this is just a prototype.

All sprites are from Unity 2D pack, the ball looks ugly because of thick outline and shadow...

3 c# scripts:
1) on the plank object to change the max/min angle limits when touched.
2) on the camera to spawn new balls every few seconds.
3) on the ball (prefab) to detect collision, check if collided hat has matching color then display result message in console, and destroy ball afterwards.

As this is using Unity Remote 4 running on iPad Mini, the screen resolution is not that good and a bit unclear.

Fatal error! The file 'MemoryStream' is corrupted! (Unity 5.3.2 on OSX 10.10.5)

Logged on to my MacBook Pro (OS X 10.10.5), connected to iPad Mini (iOS 9.3.1) with Unity Remote 4 running, started Unity (5.3.2f1), opened the same project as previous "2D/3D rotation by touch on iPad Mini" post, clicked Play, and as shown below, I get this strange message: "Fatal error! The file 'MemoryStream' is corrupted! Remove it and launch unity again! [Position out of bounds!]"


Tried shutdown and restart Unity a few times, same problem.

Searched everywhere in that project folders but couldn't anything called "MemoryStream". Searched the net and someone mentioned about removing the whole "Library" sub-folder to fix the problem... Sounds a bit dangerous to me....

Then found a simpler solution - unplug the iPad Mini, click "Play" - which worked for some reason. Then stop it, plug in the iPad Mini again, and then everything worked... Strange.

May be you are not supposed to connect to iOS device with Unity Remote 4 running before starting up Unity??

Sunday, 17 April 2016

2D/3D rotation by touch on iPad Mini


Was testing 2D/3D object rotation by touch on iPad Mini. Green circle on the left is 2D sprite. The white circle on the right is actually a sphere. Both have 4 small cubes attached as child object to make it easier to see the rotation.

Have to add extra checking to see if the touch position is above/under the centre position, or to the left/right of the centre position. As otherwise when you touch and drag on the other side of the object, it rotates in the opposite direction.

As this is using Unity Remote 4 running on iPad Mini, the screen resolution is not that good and a bit unclear.

Video taken from crappy Windows Phone 8 on Nokia Lumia 635, mainly to cut down the video file size.

Tuesday, 12 April 2016

3D Rotation Test

3D rotation test using Unity 5 buttons.


using UnityEngine;
using System.Collections;

public class Rotate1 : MonoBehaviour {


private Quaternion qTo;
private float rotateSpeed = 200.0f;
private float moveAngle = 90.0f;


void Start() {

qTo = transform.rotation;

}

void Update() {
transform.rotation = Quaternion.RotateTowards(transform.rotation, qTo, Time.deltaTime * rotateSpeed);
}

public void ToRotateLeft()
{
qTo = Quaternion.AngleAxis(moveAngle, Vector3.up) * qTo;
Debug.Log ("qTo=" + qTo);
}

public void ToRotateRight()
{
qTo = Quaternion.AngleAxis(-moveAngle, Vector3.up) * qTo;
Debug.Log ("qTo=" + qTo);
}

public void ToRotateUp()
{
qTo = Quaternion.AngleAxis(moveAngle, Vector3.left) * qTo;
Debug.Log ("qTo=" + qTo);
}

public void ToRotateDown()
{
qTo = Quaternion.AngleAxis(-moveAngle, Vector3.left) * qTo;
Debug.Log ("qTo=" + qTo);
}

public void ToRotateClockwise()
{
qTo = Quaternion.AngleAxis(-moveAngle, Vector3.back) * qTo;
Debug.Log ("qTo=" + qTo);
}

public void ToRotateAntiClockwise()
{
qTo = Quaternion.AngleAxis(moveAngle, Vector3.back) * qTo;
Debug.Log ("qTo=" + qTo);
}

}

Sunday, 3 April 2016

Shadow Test #1

Unity project testing effect of shadows of cubes/spheres with rotating point lights

Clock Test

Test project with 12 clocks based on tutorial from http://catlikecoding.com/unity/tutorials/clock/

3D Tower Test


Result of week 4 homework

Week 4 homework (https://www.youtube.com/watch?v=uIpbkCOq4lg)

Result of Week 2 homework

Week 2 homework (https://www.youtube.com/watch?v=HINWMzmNWaM)

Pendulum Test



Inspired by https://github.com/KatsuomiK/Rope

Whole Pendulum created by C# script without any prefab. Code as below, just need to attach to camera.


using UnityEngine;
using System.Collections;

public class CreateRope : MonoBehaviour {

int fragmentNum = 20;
GameObject[] fragments;
GameObject parentOfAllObjs;

Vector3 interval = new Vector3(0f, 0f, 0f);

void Start () {

parentOfAllObjs = new GameObject("Pendulum");
parentOfAllObjs.transform.position = new Vector3 (10f, 0f, 10f);

GameObject chainObj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
chainObj.transform.localScale = new Vector3 (0.25f, 1.0f, 0.25f);
Rigidbody rb = chainObj.AddComponent<Rigidbody>(); // Add the rigidbody.

fragments = new GameObject[fragmentNum];

Vector3 position = parentOfAllObjs.transform.position;

for (int i = 0; i < fragmentNum; i++) {
fragments[i] = (GameObject) Instantiate(chainObj, position, Quaternion.identity);
fragments[i].transform.parent = parentOfAllObjs.transform;
fragments[i].name = "fragment-" + i.ToString ();
fragments [i].transform.localPosition = i*interval;

HingeJoint joint = fragments[i].AddComponent<HingeJoint>();
joint.autoConfigureConnectedAnchor = false;
joint.connectedAnchor = new Vector3 (0f, 0f, 0f);

if (i > 0)
{
joint.connectedBody = fragments [i - 1].GetComponent<Rigidbody> ();
}
}

GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.name = "Ball";
sphere.transform.parent = parentOfAllObjs.transform;
Rigidbody gameObjectsRigidBody = sphere.AddComponent<Rigidbody>(); // Add the rigidbody.
gameObjectsRigidBody.mass = 50;

HingeJoint fj = sphere.AddComponent<HingeJoint> ();
fj.autoConfigureConnectedAnchor = false;
fj.connectedAnchor = new Vector3 (0f, 0f, 0f);
fj.connectedBody = fragments [fragmentNum - 1].GetComponent<Rigidbody> ();

Destroy (chainObj);

}
}