Code Monkey home page Code Monkey logo

gear-vr-leap-unity's Introduction

gear-vr-leap

Workaround in Unity to use Leap Motion Controller with Gear VR (or any other headset that doesn't support it)

Motivation

It is currently "impossible" to use Leap Motion with the Gear VR (in Unity 3D). You can't plug in the Leap to the phone or the Gear and access it's data from there. Furthermore, Leap Motion's Android SDK is (as of this writing) in alpha (invite only, with invites closed).

How it works

The repository is a Unity package that leverages Unity Networking over a local wifi connection between the Android device and a PC.

The Android device/application acts as the server and while the PC Application acts as the client. Both devices need to be on the same local network.

The client player consists of two custom knobby hand prefabs (created following this tutorial) and the camera object. The client player's hands is being controlled by the Leap Motion using the official Leap core assets and SDK.

The client player will be spawned on the server with it's Transform being sent over the local network to the server using Unity's NetworkTransform and NetworkTransformChild.

Conceptually, this is a simple multiplayer game where the movement of one player gets streamed for the other player to view.

High level schematic

high level schematic

Note

The Rigidbody version of the hands (separate Leap provided GameObject that contains the colliders of the fingers) is not set to stream its movement to the mobile app. This can be done by adding more NetworkTransformChild components and putting the bone colliders as the target transform.

Example(s)

You can download the example APK and EXE here All you need to do is run the app(s) and follow the steps in "How to use it", starting from step 9.

Prequisites

It is important to already have Leap Motion working in your Unity Project.

  • Make sure you have the Leap SDK Installed. Get it here
  • Also, if you're using the free version of unity, make sure you've done this

How to use it

  1. Fork/clone this repository. (Apologies. This might take a while; large files)
  2. Connect your android device and smart phone to the same local network.
  3. In the gear-vr-leap packages folder, there are two packages. One for the mobile app and one for the PC app. They're essentially the same. Only difference is that one (mobile) of them starts in VR mode. Import the appropriate package into your unity project.
  4. If you already have Google VR and Leap Motion packages in your project, do not forget to deselect them during importation.
  5. Make sure to add the scenes in the package to your build.
  6. Build the appropriate project for android and have it run on your smartphone.
  7. Run the appropriate project on your computer too. (Make sure you have the Leap Motion device connected)
  8. On the android smartphone, click "Server". The IP address of the device will be displayed.
  9. On the PC, click "Client". Then enter the IP address of the server,
  10. On the android smartphone, click "Create Room" (to begin the online session).
  11. On the PC, click "Join Room" (to join this session).
  12. Now you may move your hands over the leap motion and watch your actions be mirrored on the smartphone.

With this as a base, you can proceed to build your Leap controlled Gear VR game. The only drawback is that your leap has to be tethered to the PC via USB.

Building your own application

Once the connection has been made and the session is joined, the game will be moved to the Online Scene. This is where all the additions you need to make to your game/experience should be.

Furthermore, you only need to work on the Online Scene within your Android Unity Project, you don't need to keep making changes to the Unity Project that builds for PC.

However, you need to note that the exact same character prefab (the hands) need to be present in the PC/Desktop Unity Project, including the meta files. It is this prefab that you'll have to work on if you want to modify/change how hands are displayed in your game.

Screenshots

screenshots

Contributing

Please help make this better by making pull requests and posting issues. There are probably a lot of bugs and things that can be made better because we're relatively inexperienced with Unity. All contribution is welcome.

Contribution commits should be made in the gear-vr-leap-mobile and gear-vr-leap-pc folders. Those are the Unity Projects from which the packages are created.

gear-vr-leap-unity's People

Contributors

gazuntype avatar timigod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gear-vr-leap-unity's Issues

Create room not working

Does it need to change network info in Unity properties tab or use by default 192.168.1.5 in controller script. I tried to use default and change to my pc network address, but it still doesn't work. After I click create room on mobile, nothing happen. thanks

"HandRepresentation' error

Hi,

I'm getting this error. Any idea what could be the problem? I've followed every step you suggested.

Assets/LeapMotion/Scripts/HandRepresentation.cs(9,25): error CS0101: The namespace Leap.Unity' already contains a definition for HandRepresentation'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.