Home / Demo / Star Wars Lightsaber with Unity and Leap Motion

Star Wars Lightsaber with Unity and Leap Motion

/
/
/
1297 Views

This week, I want to share with you, my Star Wars Lightsaber project.

I’ve implemented it on May 4th to celebrate the Star Wars day. It’s a simple Unity project where you can control a 3d Star Wars lightsaber using a Leap Motion.

  Complete project on GitHub

Star Wars Lightsaber 3d Model

First, I’ve used Blender to create a 3d model based on the Anakin’s lightsaber. It’s not very detailed, doesn’t have textures but it gets the job done.

star wars lightsaber 1

star wars lightsaber 2


Unity Core Assets

Then, I’ve imported the Unity Core Assets and used the following Unity Modules:

Attachments Module

It provides a utility hand model with quick access to the several parts of the hand (more…).

I’ve used it to add an empty gameObject to the Right Hand Palm. It works as the parent object for the lightsaber when the player is holding it. IMAGE1

Detection Utilities

In this Module, there are Detectors and Detector Logic Gates (more…). A Detector helps identify several hand and finger positions. A Detector Logic Gate combines individual detectors and returns the global result.

Detectors

Fingers extended; IMAGE2
Fingers not extended; IMAGE3
Palm Forward; IMAGE4
Palm Down; IMAGE5

Detector Logic Gates

Grab IMAGE6

  • Used to grab the lightsaber;
  • Combines the Palm Forward with the Extended Fingers;

Enable IMAGE7

  • Used to switch on/off the lightsaber;
  • Uses the Not Extended Fingers Detector (I don’t remember why I used a logic gate while a single detector was enough);

Release IMAGE8

  • Used to release the lightsaber;
  • Combines the Palm Down with the Extended Fingers;

Hand Assets

I’ve only used the Rigged Hands prefab (more…).


Unity Components

LeapController.cs IMAGE9

  • Implements the Grab, Enable and Release actions;

Lightsaber.cs IMAGE10

  • Controls the lightsaber light animation (particle system and scale);
  • Controls the lightsaber sounds.

Don’t forget to check the complete project on GitHub.

Happy Coding 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *