[Plugin] Leap Motion - Event Driven

I’m having many issues as all the nodes used in these examples are not in the blueprints. the blue pin off the execute doesn’t drag off the metacarple node or any of the other finger joints. All i find is stabilized tips for a numbered pointer witch seem to be finger tips but do no move in or out. only up down left and right. also if someone can help me how do you make a varaible from one of the bone joints to call in animation blueprint I have left clicked silly on everything I can think of and can’t find a link.

Follow the shipping instructions found in the main plugin documentation( repo). These specify:

The following things must be done, none of them are optional.

  1. Add code to project, it doesn’t have to do anything but you must have that part so that the plugin gets compiled and linked with the final build
  2. Add the following line to your DefaultEngine.ini (found in {Project Root}/Config)
    EnabledPlugins=LeapMotion under [Plugins], create this category if missing (part may be optional for a development build). It should look like:
  1. Package your project, both development and shipping is supported, pick your target and package.
  2. In your packaged directory drag the **Binaries **folder from the plugin into your packaged project folder. E.g. if I have a packaged folder called *LeapPluginTest *find WindowsNoEditor/LeapPluginTest, this is your packaged project root. Add the binaries folder there.

If you get errors complaining ‘Leap Motion’ plugin cannot be found, you do not have code in your project.
If you get errors complaining the ‘Leap.dll’ is missing, you did not drag binaries to the correct location.

Grab the latest download from (link is always at the beginning of this thread), the current version is 0.7.2.

All the documentation found at the repo and in this thread is up to date. Use events where possible as they filter to only fire when relevant (I.e. if your hand isnt being tracked you will not get any hand/finger events, when you move your hand into view, they will fire), and they will have the contextual data you need available right from the event node.

First of all, I noticed that I was not using the current build 0.7.2. Updated and fixed all errors inside blueprints. So far so good! Works perfect inside editor.

After those steps, I get several errors when I try to compile. Most of the errors are like these:

And the list goes on for all the header files. I’m not a C++ programmer so I may be making some mistake.
Just to make clear. Do I need to compile and link the LeapSDK with the Unreal code? I don’t think so, since the LeapSDK is already inside your build.
What I’m missing?

[BUG]
There’s a bug in the “Time Visibility”. If you keep your hands in the leap for 60 seconds, it freezes. Happens when the clock reaches 59 seconds to 60 seconds. It’s probably turning the clock to zero and then dividing something.

Tested this in blueprint for both finger and hand (finger is a subclass of pointable, the only other class that has timeVisible code), it printed for longer than 60 seconds without issue, so I could not replicate this bug. The code is simply a pass-through for the underlying leap object, so it shouldn’t be the reason for a bug. Are you referring to ‘getFrame’ instead which supports up to 60 frames (valid index 0-59)? Please elaborate what specific setup/steps cause this bug to show up?

First of all what build type are you trying to do? Are you packaging your project? (File->Package->Platform->x64/x32) Is it shipping or development build? Please be as specific as you can in terms of what you’re doing, for example Launch is not supported due to lack of automatic dll copying in packaging process, but packaged shipping/development builds are.

From my understanding of how the compilation works, for both development and shipping build, the game collapses the plugin into the build and because of this requires the project to have code so that the compiler includes the plugin source in the build. This is a limitation of the shipping process for plugins as far as I am aware. But you should not need to have any additional code or step beyond what is mentioned in the shipping instructions.

Either way, I’ve tested the shipping instructions several times and they work on my end, perhaps they are not clear enough or you are doing something unexpected, walk me through your packaging process as well the project context (C++ base, blueprint base, leap component added to character subclass/etc).

Also please ensure you DELETE the old plugin(if you have no other plugins, simply delete the Plugins folder from your project) when upgrading, as you may get duplicate classes otherwise which may cause errors when you compile.

Hey guys, I’m having a bit of difficulty putting this to work. So, I downloaded the latest leap-ue4-master. I created a pawn blueprint with all the correct nodes (I copied exactly from the instructions), and inserted interface on blueprint props. But when I press play nothing happens!
Any idea of what might be? Thanks!

You need to add a Leap component in addition to add the interface. Without the component your interface events will never fire!

Two methods of adding a component are:
Option A: Adding Component Directly


Option B: Adding Component through event graph

I added through the Option B, and I even ticked all the HMD options because I’m using with the Oculus.
But still, nothing happens.

I recommend not using the rift first, but ensure it works by using the regular on-table placement and showing the debug hands. You may be simply not seeing the hand because it is off-screen. Understand that using Optimize for HMD will adjust the positions are rotations with the expectation that you have your leap mounted, essentially requiring you to put on the hmd to preview the hands.

Hm, that makes sense. I’ll try it.

Also I think this may have to do with my pawn blueprint. I don’t know if I’m controlling it. I tried searching for pawn tutorials but no results. After I create pawn should I just drag and drop or do I need to do something with it?

This really covers basics, so I recommend following unreal tutorials first. That said you need to make sure that the pawn is set as the default pawn in your game mode.

Heh, thanks but I’ve been working with UE4 for some time now (but mainly just making level design). I know the basics except for the classes and blueprints part, I can only make openable doors lol.

“That said you need to make sure that the pawn is set as the default pawn in your game mode.” - Yeah I did that but it doesn’t really affect my level. I can’t move anymore after I do that, but maybe the player controls are inside the default pawn. I still have a lot to learn ^^

Do i need to add stuff to the components part? Because there’s nothing there right now. I tried adding a camera but that didn’t help much.

Did you enable the leap blueprint props? Its at the top of your BP next to the compile and save button.

I’ve been able to compile a new project. So I will test in my main project and see what happens.

Leap still crashes with a very simple project. I have nothing but the character in the scene with this setup inside blueprints character.
It crash both in the editor and the compiled project. It actually crash around 40 to 59 seconds.

Hey since you’re a programmer I assume you understand the leap API well enough. I’ve been looking at the best way to get the rotation data and give that to the hand bone. I’ve been using palm normal and direction but my understanding is that the hand bone rotates at the wrist while the leap is grabbing the rotation from the center of the palm, is there a way to correct this?

Tried in another computer and the engine still crashes. I notice that my actor (character) gets delete after 60 seconds. The engine does not crash until “Event Hand Moved” is activated.
Maybe there’s a UPROPERTY missing and the garbage collector is deleting the actor or component.
Does anybody can replicate it?

NB: Rotation is location independent, you can easily use the palm orientation (and this is what you are looking for) and use it to rotate the wrist bone in your skeleton.

Out of curiosity I took a look at this. Referring to the Leap API you can see that there are the two vectors reported that are relevant (as you mentioned). These are palmNormal() and direction(). Now one way you can get your orientation is by doing the following:



    float pitch = hand.direction().pitch();
    float yaw = hand.direction().yaw();
    float roll = hand.palmNormal().roll();

But since UE blueprints have convenience nodes, I find it easier to do the following


Which is simply taking the normal and the direction and making a rotator from the Z and X axis, that’s it.

We can show this is correct by using a convenience debug function like this


which gives the following result (along with debug showing finger positions for context)


Also noticed that the palm normal was being scaled (which it shouldn’t be) so I fixed that and updated the plugin to 0.7.3. This wouldn’t affect the above graph however.

I have tried your example in the third person blueprint template and it isn’t crashing for me, let’s try to narrow this down. Make a new project, run me through which type of project (e.g. 3rd person template, blueprint) /etc so I can replicate it exactly. Also if you can send me your logs (found in {Project Root}/Saved/Logs), we should be able to identify what is going on.

It is probably best that you start with a template character which will have all the movement input bindings conveniently set up. For really basic movement you can simply re-parent your pawn to Character.h.

I was working through this thread last night and encountered the same crash after 60 seconds that some of you are getting. It turns out that when following the instructions at the top of the thread (step 5), I had added the leap component in both the component tab AND in the event graph, instead of just doing one or the other. Simply removing the leap component from the component tab fixed the crash for me.

Just created a First Person Blueprint and added the Leap Event Interface to the Character with a Stabilized Palm Position pointing to a Debug Sphere.
After 60 seconds it crashed.