Presentation is loading. Please wait.

Presentation is loading. Please wait.

Myo + Oculus Rift Tutorial

Similar presentations


Presentation on theme: "Myo + Oculus Rift Tutorial"— Presentation transcript:

1 Myo + Oculus Rift Tutorial
Chris

2 Download the game at chrisjz.github.io/myogic
Content Develop simple mage game in virtual reality Shoot magic projectiles using hand gestures Aim by rotating arm Defeat hoard of spiders Download the game at chrisjz.github.io/myogic

3 Myo Dev Kit EMG sensors for gesture detection Gyroscope Accelerometer
Magnetometer Bluetooth Full day battery charge Download link to Myogic alpha version:

4 Myo Dev Kit vs Leap Motion
MDK Leap Motion Fixed gestures (six) 2D arm tracking Wireless Finger tracking 3D hand tracking HMD Mountable Myo developers did mention that a future release would provide developers with raw EMG data which will open up possibilities for many more gestures.

5 Wireless VR Why Myo? Allows for wireless VR with motion controls
I.e. Gear VR + Myo

6 Requirements IDE Myo Rift DK2 Unity Pro 4.6+
Myo Connect (Win/Mac) SDK Beta 7+ (Win/Mac) Rift DK2 Unity 4 Integration Unity package is included in the SDK.

7 Scope Integrate Oculus VR player into game scene
Attach Myo controller to arm-hand model Map several magic attacks to hand gestures

8 Download the game at chrisjz.github.io/myogic
Getting Started Download the source code for Myogic at github.com/chrisjz/myogic Create a folder in the Assets directory called TutorialScenes. Copy the scene and corresponding folder from Palace of Orinthalian > [Scenes] to TutorialScenes. Open the copied scene. Download the game at chrisjz.github.io/myogic

9 Create OVR Player Add the OVRPlayerController prefab into the root [Character] gameobject. Disable the existing First Person Controller gameobject. Feel free to place the player anywhere in the scene. OVRPlayerController prefab is located at OVR > Prefabs.

10 Hand Model Positioning
In the gameobject OVRCameraRig create the gameobjects Hands > Right. Place the prefab GlowRobotFullRightHand in Right and position it on the right of the player’s view. Set scale of the right hand to 5x5x5. GlowRobotFullRightHand prefab is located in LeapMotion > Prefabs > HandGraphics.

11 Integrate Myo Controls with Hand
Place the Hub – 1 Myo prefab in the root of the hierarchy. Attach the script JointOrientation to the OVRCameraRig > Hands > Right gameobject. Drag the Myo gameobject into the Myo variable in the JointOrientation script. The JointOrientation script will map Myo’s gyroscope based movements to the arm model. Hub – 1 Myo prefab is located in Myo > Prefabs. The bug fix though has a setback where the player won’t be able to rotate and can only move forwards, backwards and strafe sideways. Bug fix: Set Rotation Amount to 0 in OVRPlayerController as JointOrientation has an existing bug where the arm rotates incorrectly when the player rotates.

12 Setup Magic Powers Create a Plane object under Right gameobject and position in front of the hand model’s index finger. Name the plane object MagicLauncher and disable its Mesh Collider and Mesh Renderer and ensure its X axis faces forward from finger. Attach a new C# script called MagicController on Right gameobject. Resize the plane to the dimensions of a finger to make it easier to place it.

13 MagicController.cs (1) using UnityEngine; using System.Collections; using Pose = Thalmic.Myo.Pose; public class MagicController : MonoBehaviour { // Myo game object to connect with. // This object must have a ThalmicMyo script attached. public GameObject myo = null; // Point from where magic projectiles will launch from the hand. // This object must be a plane placed either in front of the palm or at the tip of the hand's fingers. public GameObject handMagicLauncher; public GameObject fistProjectile; public GameObject waveInProjectile; public GameObject waveOutProjectile; // Speed of projectile public float fistSpeed = 1000; public float waveInSpeed = 1000; public float waveOutSpeed = 1000; // Cooldown until next projectile can be launched public float projectileCooldown = 1; protected ThalmicMyo myoController = null; private float projectileTimer = 0; Setup variables for the scene’s myo object, the hand magic launcher and the projectile attributes that map to the 3 used myo gestures.

14 MagicController.cs (2) void Start () { myoController = myo.GetComponent<ThalmicMyo> (); } void Update () { if (!myo && !myoController) return; if (projectileTimer > 0) { projectileTimer -= Time.deltaTime; } else { projectileTimer = projectileCooldown; switch (myoController.pose) { case Pose.Fist: Attack (fistProjectile, fistSpeed); break; case Pose.WaveIn: Attack (waveInProjectile, waveInSpeed); case Pose.WaveOut: Attack (waveOutProjectile, waveOutSpeed); Projectiles will have a cooldown before they are re-launched, which you can set with the public variable projectileCooldown. The Attack function will be called based on which of the 3 myo gestures are detected, with the magic projectile object (a prefab we will set soon) and the speed of the projectile passed into this object.

15 MagicController.cs (3) protected void Attack(GameObject projectilePrefab, float speed) { GameObject projectile; projectile = (GameObject) Instantiate (projectilePrefab.gameObject, handMagicLauncher.transform.position, Quaternion.identity); projectile.rigidbody.AddForce (handMagicLauncher.gameObject.transform.forward * speed); } The Attack method handles all the magic shooting itself. An instance of the projectile object will be created at the position of the MagicLauncher object we positioned in front of the hand earlier. The Quaternion.identity parameter will ensure the projectile faces the default X axis direction. Now we will throw the projectile by adding force in the forward direction of the handMagicLauncher at the projectile’s defined speed.

16 Set Magic Public Variables
In the MagicController script, set the following for the public variables: Myo – Drop in the scene’s Myo object. HandMagicLauncher – Drop the MagicLauncher object under the Right gameobject. “—” Projectiles – Set as any of the projectile prefabs in Projectiles > Prefabs. Optionally you can also change the speed of each projectile and the cooldown period.

17 Extras Add enemy spiders to the scene from Enemies > Spider > Prefabs and play around with its health, speed, FOV, size etc. Add new magic attacks and change their attributes. Add player health and damage to make the game more challenging. For new magic projectiles, you can find more in KY_magicEffectsFree > prefab. Just make sure you add a rigidbody, collider and at least the MagicProjectile.cs script. See the existing projectile prefabs in Projectiles > Prefabs for guidance. When playing the game, you can re-calibrate the arm’s position by pressing the “r” key or doing the fingers spread gesture. There are currently no scripts to add health and damage to the player, this is for you to figure out!

18 Good Luck!


Download ppt "Myo + Oculus Rift Tutorial"

Similar presentations


Ads by Google