Introduction


Welcome to the GM Motion v2.3!

GM Motion is an extension for GameMaker that lets you use the Leap Motion as an input and use your hands to control your game. This site covers the basics of how to use the extension and all the functions it includes.


Let’s get started!

Getting Started


So you want to start developing with the Leap Motion? Awesome!
First we need to setup a few things, you will need:

Leap Motion

Obviously one of the critical points for using this extension, is the Leap Motion device itself. There are several ways to get your hands on one:

GameMaker

This extension will work for Game Maker 8, 8.1 and Studio, however, in the guide I will assume you are using Studio and won’t be covering any pre-studio specifics.
For the most part everything should be the same.
Don’t forget you can pick up the standard version of Studio for free.
www.yoyogames.com/studio

Leap Motion Drivers

You will need version 2.0 drivers or later to use this extension. If you try to run it with earlier drivers, you’ll likely be greeted with many errors.
You can get the latest public drivers at:
www.leapmotion.com/setup
If you want to access to the SDK and beta versions then sign up as a developer (it’s free) at:
developer.leapmotion.com

Let’s Go!


So you’ve got your Leap Motion, latest drivers installed, and GameMaker ready to go… but there’s one key piece we still need!
GM Motion!
If you downloaded the complete package then you’ll have everything you need, otherwise head over to www.jimmybg.com/gm-motion/ and hit download up the top.

 

Extract the zip and you’ll be greeted with the following files:


Installing GMMotion.lib

If you’re going to use GM Motion purely with GML then you can skip this part, otherwise read on.
To add the "GM Motion" tab (action library) to the object properties window you need to copy the GMMotion.lib into GameMaker’s “lib” folder.

Here are the standard places you will find the folder (it may be different on your computer)

Once you have copied GMMotion.lib to the “lib” folder, open up GameMaker with a new project (if you already had GameMaker open you’ll need to close it and reopen it)


As a quick test, create a new object and check on the right that you have a tab called “GM Motion”, and when selected it looks like the image below:

Adding the GMMotion extension to your project

If you’re using Studio you simply need to import the GMMotion.gmez extension:

If you’re using 8 or 8.1, you need to import the script file GMMotion.gml and place the GMMotion.dll and Leap.dll in the same directory as your source file.

 

That’s it! You’re officially ready to use your Leap with GameMaker!

List of Functions


Here are a list of all the functions in GM Motion, there are a few things to know about the data GM Motion returns and also what it expects to receive (arguments):

 Function

 Use / Description

leap_init()

Connect to the Leap Motion device (runs leap_dll_init)

leap_hands()

Returns the number of hands visible

leap_hand_x(hand)

Returns the x position of the specified hand

leap_hand_y(hand)

Returns the y position of the specified hand

leap_hand_z(hand)

Returns the z position of the specified hand

leap_hand_vel_x(hand)

Returns the x velocity of the specified hand

leap_hand_vel_y(hand)

Returns the y velocity of the specified hand

leap_hand_vel_z(hand)

Returns the z velocity of the specified hand

leap_hand_roll(hand)

Returns the roll angle of the specified hand

leap_hand_pitch(hand)

Returns the pitch angle of the specified hand

leap_hand_direction(hand)

Returns the direction/yaw angle of the specified hand

leap_hand_no(hand side)

Returns the hand number for the specified side, use this to keep track of which is the left and right hand

leap_hand_type(hand)

Returns true if the hand is left, false if right

leap_hand_grab(hand)

Returns the grab strength of the specified hand

leap_hand_pinch(hand)

Returns the pinch strength of the specified hand

leap_fingers()

Returns the number of fingers visible

leap_finger_x(hand, finger)

Returns the x position of the tip of the specified finger

leap_finger_y(hand, finger)

Returns the y position of the tip of the specified finger

leap_finger_z(hand, finger)

Returns the z position of the tip of the specified finger

leap_finger_name(finger)

Returns the name of the specified finger

leap_bone_x(hand, finger, bone)

Returns the x position of the specified bone

leap_bone_y(hand, finger, bone)

Returns the y position of the specified bone

leap_bone_z(hand, finger, bone)

Returns the z position of the specified bone

leap_bone_roll(hand, finger, bone)

Returns the roll angle of the specified bone

leap_bone_pitch(hand, finger, bone)

Returns the pitch angle of the specified bone

leap_bone_direction(hand, finger, bone)

Returns the direction/yaw angle of the specified bone

leap_gestures()

Updates the status of gestures

leap_swipe_direction()

Returns direction of a swipe in degrees

leap_swipe_speed()

Returns speed of a swipe

leap_circle_direction()

Returns direction of a circle, 1 or -1 (clockwise or anti-clockwise)

leap_circle_progress()

Returns the progress of a circle, e.g. 2.5 = 2 and a half circles completed

leap_circle_radius()

Returns the radius of a circle

The following are for GMMotion.dll, use leap_dll_free() when you’re finished using the leap

leap_dll_init()

Sets up access to GMMotion.dll’s functions, this is run by leap_init(), there is no need to run it manually

leap_dll_free()

Free GMMotion.dll from memory

FAQ / Troubleshooting


Q. My object isn’t moving/I’m not getting any data/why isn’t it working?!

A.

Have you plugged in your Leap? Check that the Leap Motion Control Panel Icon (bottom right in taskbar) is green. Got that too? Then right click the Leap Motion Control Panel and select “Visualizer”, this will show a 3D display of the hands the Leap can see. If you’re not getting anything in the Visualizer, then head over to the Leap Motion support page https://support.leapmotion.com/home
If the Visualizer is working, and you’re absolutely sure you’ve got everything right in your project - Contact Me!


Q. Function someleapfunction not found!

A.

You tried looking at the GML file in the extension didn’t you? DON’T, GameMaker will modify them when you open them and mess up access to the functions. You’ll need to delete the extension from your project and import it again. Also, the scripts are in a separate GML file GMMotion.gml for you to look at / use / modify.

Useful Links & Contact


Here’s a few sites I recommend for learning/getting help with GameMaker:

Sites:

forum.yoyogames.com - GameMaker Community forum

gmc.yoyogames.com - Old GameMaker Community forum (GMC) *ARCHIVED* but still great place for finding tutorials and answers.

reddit.com/r/gamemaker - GameMaker subreddit, quite active and plenty of helpful users.

docs.yoyogames.com - GameMaker’s official documentation, also available by pressing F1 when in GameMaker.


Contact Me

If you’ve got a question or need help with GM Motion, tweet or pm me: twitter.com/jmybg
Or email me at: hello@jimmybg.com

 

Copyright © James Begg 2017