[Plugin] Leap Motion - Event Driven

Glad my plugins can be of use!

To access leap motion from C++, do the same thing you would do in blueprint but using the C++ methods. If you’re confident you should probably use the custom approach as it will give you more direct control and flexibility which is what I’m assuming your C++ approach is about.

  1. Attach a component to your pawn/actor.

  2. Use the LeapEventInterface via multiple-inheritance

Now you will receive the same events you would get in blueprints, all defined in the LeapEventInterface class. Then you can follow the same instructions found at the repository readme, pay attention for example to the Example ‘Debug Hand’ graph on how to get basic hand information.

You have nearly complete access to the Leap API through the UE components which handle all orientation and unit conversion, but since you’re in C++ you can also query the leap directly after including the necessary headers, e.g. using the pure Leap API Leap Controller


Leap::Controller leap;

See my unreal ULeapController component class for use examples.

On the topic of recreating the VRController, all it does is ensure that your camera is separated from your view controller rotation. You can follow this wiki for an example of how to do that in C++.

All the convenience characters such as RiggedCharacter are a bit more complex. What they do is contain an actor called LeapAnimBodyConnector or its subclass, which handles all the leap-specific interaction and stores it in an AnimBody data structure class. Then in the Animation Blueprint of the skeletal mesh, it looks for the AnimBody and copies its current state to the skeletal mesh, blending in animation when information is not being sent. This means the animation blueprints and characters are agnostic to the input, and the only leap specific part is the LeapAnimBodyConnector.

I haven’t had the opportunity to explore how animation blueprints can be set in C++, if you find out how to do that, some guidance on it would be awesome and might help pave the way for easier skeletal mesh swapping in the future.