Myo Oculus Rift Tutorial Chris Zaharia chrisjz Content

  • Slides: 18
Download presentation
Myo + Oculus Rift Tutorial Chris Zaharia @chrisjz

Myo + Oculus Rift Tutorial Chris Zaharia @chrisjz

Content • • Develop simple mage game in virtual reality Shoot magic projectiles using

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

Myo Dev Kit • • • EMG sensors for gesture detection Gyroscope Accelerometer Magnetometer

Myo Dev Kit • • • EMG sensors for gesture detection Gyroscope Accelerometer Magnetometer Bluetooth Full day battery charge

Myo Dev Kit vs Leap Motion MDK Leap Motion • Fixed gestures (six) •

Myo Dev Kit vs Leap Motion MDK Leap Motion • Fixed gestures (six) • 2 D arm tracking • Wireless • Finger tracking • 3 D hand tracking • HMD Mountable

Wireless VR

Wireless VR

Requirements • IDE • Unity Pro 4. 6+ • Myo Connect 0. 7. 0+

Requirements • IDE • Unity Pro 4. 6+ • Myo Connect 0. 7. 0+ (Win/Mac) • SDK Beta 7+ (Win/Mac) • Rift DK 2 • Unity 4 Integration 0. 4. 4+

Scope • Integrate Oculus VR player into game scene • Attach Myo controller to

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

Getting Started • Download the source code for Myogic at github. com/chrisjz/myogic • Create

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

Create OVR Player • Add the OVRPlayer. Controller prefab into the root [Character] gameobject.

Create OVR Player • Add the OVRPlayer. Controller prefab into the root [Character] gameobject. • Disable the existing First Person Controller gameobject.

Hand Model Positioning • In the gameobject OVRCamera. Rig create the gameobjects Hands >

Hand Model Positioning • In the gameobject OVRCamera. Rig create the gameobjects Hands > Right. • Place the prefab Glow. Robot. Full. Right. Hand in Right and position it on the right of the player’s view. • Set scale of the right hand to 5 x 5 x 5.

Integrate Myo Controls with Hand • Place the Hub – 1 Myo prefab in

Integrate Myo Controls with Hand • Place the Hub – 1 Myo prefab in the root of the hierarchy. • Attach the script Joint. Orientation to the OVRCamera. Rig > Hands > Right gameobject. • Drag the Myo gameobject into the Myo variable in the Joint. Orientation script. Bug fix: Set Rotation Amount to 0 in OVRPlayer. Controller as Joint. Orientation has an existing bug where the arm rotates incorrectly when the player rotates.

Setup Magic Powers • Create a Plane object under Right gameobject and position in

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 Magic. Launcher and disable its Mesh Collider and Mesh Renderer and ensure its X axis faces forward from finger. • Attach a new C# script called Magic. Controller on Right gameobject.

Magic. Controller. cs (1) using Unity. Engine; using System. Collections; using Pose = Thalmic.

Magic. Controller. cs (1) using Unity. Engine; using System. Collections; using Pose = Thalmic. Myo. Pose; public class Magic. Controller : Mono. Behaviour { // Myo game object to connect with. // This object must have a Thalmic. Myo script attached. public Game. Object 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 Game. Object hand. Magic. Launcher; public Game. Object fist. Projectile; public Game. Object wave. In. Projectile; public Game. Object wave. Out. Projectile; // Speed of projectile public float fist. Speed = 1000; public float wave. In. Speed = 1000; public float wave. Out. Speed = 1000; // Cooldown until next projectile can be launched public float projectile. Cooldown = 1; protected Thalmic. Myo myo. Controller = null; private float projectile. Timer = 0;

Magic. Controller. cs (2) void Start () { } void Update () { myo.

Magic. Controller. cs (2) void Start () { } void Update () { myo. Controller = myo. Get. Component<Thalmic. Myo> (); if (!myo && !myo. Controller) return; if (projectile. Timer > 0) { projectile. Timer -= Time. delta. Time; return; } else { projectile. Timer = projectile. Cooldown; } } switch (myo. Controller. pose) { case Pose. Fist: Attack (fist. Projectile, fist. Speed); break; case Pose. Wave. In: Attack (wave. In. Projectile, wave. In. Speed); break; case Pose. Wave. Out: Attack (wave. Out. Projectile, wave. Out. Speed); break; }

Magic. Controller. cs (3) protected void Attack(Game. Object projectile. Prefab, float speed) { Game.

Magic. Controller. cs (3) protected void Attack(Game. Object projectile. Prefab, float speed) { Game. Object projectile; projectile = (Game. Object) Instantiate (projectile. Prefab. game. Object, hand. Magic. Launcher. transform. position, Quaternion. identity); projectile. rigidbody. Add. Force (hand. Magic. Launcher. game. Object. transform. forward * speed); } }

Set Magic Public Variables • In the Magic. Controller script, set the following for

Set Magic Public Variables • In the Magic. Controller script, set the following for the public variables: – Myo – Drop in the scene’s Myo object. – Hand. Magic. Launcher – Drop the Magic. Launcher 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.

Extras • Add enemy spiders to the scene from Enemies > Spider > Prefabs

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.

Good Luck!

Good Luck!