Control your LightSaber with Littlebits! Mixing real world gadgets with virtual reality tools. The handle is built from paper craft, added with controls from Littlebits. I used the wireless receiver and transmitter and cloudbit to send commands to an Augmented Reality App using WebSockets in Unity3d.
Developing Augmented Reality apps is interesting. But connecting it to Littlebits added a whole new level of interaction. Respect this project if you agree. Share the magic and follow me.
This project won the Littlebits Bit Wars Challenge. Check it out at
http://littlebits.cc/announcing-the-bitwars-challenge-winners
HOW TO MAKE IT
STEP 1 : Print and assemble Papercraft LightSaber
Here's the link to the Star Wars Lightsaber Printable.
http://family.disney.com/craft/star-wars-lightsaber-printable
You'll need - 1 empty paper towel roll - Glue or tape - Scissors
STEP 2 : Connect the Wireless Receiver to the Cloudbit
Make sure your Littlebits Cloudbit is setup properly.
This will send data received from the wireless transmitter to Cloudbit. I tried connecting it directly but I found out the cloud bit needs more power than a 9v battery, so you'll need a wireless transmitter and receiver.
STEP 3 : Connect the Dimmer to Wireless Transmitter
The 9v battery connects to the Dimmer and Wireless Transmitter and tucked inside the Paper Towel Roll LightSaber. I drill a hole to plug the dimmer.
STEP 4 : Create a Unity3d Augmented Reality App
I created an Augmented Reality Android App in Unity that communicates with Cloudbit using websockets. I am using Vuforia to track the LightSaber handle.
I couldn't publish the Unity3d project since it includes assets that are licensed.
This is a good tutorial on how to track a cylinder in Unity3d. Thanks to Edgaras Art.
Instead of tracking a can, I track top half of the PaperTowel Roll which is the first page of the LightSaber printout.
Diameter = 1.7
Length = 5.5
Here's an asset in unity3d that connects to websockets https://www.assetstore.unity3d.com/en/#!/content/8959 - To save some money, I actually compiled the open source websocket-sharp.dll and include it to my project - http://sta.github.io/websocket-sharp/
- You may also need to copy Newtonsoft.Json dlls to your project. I copied it under Plugins folder.
I also attached a C# code snippet in Unity3d on how to connect to littlebits using Websockets.
https://gist.github.com/rondagdag/4bff1724cdf624b04db8
So, when we receive a message from Cloudbit, we change the local velocity value of the lightsaber gameobject. That's it....
// when we receive a message from littlebits, we need to parse the data
ws.OnMessage += (sender, e) =>
{
var data = e.Data.Substring(1,e.Data.Length -2);
var newData = data.Replace("\\", "");
JObject json = JObject.Parse(newData);
var payload = json["payload"];
if (payload != null)
{
var newValue = payload["percent"].Value<int>();
//if (value != newValue)
{
energyScript.LocalVelocity_Y = value / 10;
}
value = newValue;
Debug.Log ("Cloudbit:" + value);
}
};
Here's also an asset for LightSaber Energy Sword https://www.assetstore.unity3d.com/en/#!/content/10003
I got the sounds from here: http://soundbible.com/tags-lightsaber.html
I couldn't publish the whole source code since there are assets that cannot be shared. For Personal Use license.
Doing Augmented Reality is fun, But combining it with the cloud and hardware like Littlebits is way cooler. If you like to see more projects like this, please add respect and follow me.
Comments