Skip to content

Instantly share code, notes, and snippets.

@romualdo97
Last active July 16, 2020 18:44
Show Gist options
  • Save romualdo97/baf044cb2216e14c12954581ff3680af to your computer and use it in GitHub Desktop.
Save romualdo97/baf044cb2216e14c12954581ff3680af to your computer and use it in GitHub Desktop.
The volkano project core

This class is basically a rudimentary state machine, the states are set by calling rightVolcanRotate(), rightVolcanStop(), leftVolcanRotate(), and leftVolcanStop(). Those methods are invoked by the leap motion unity SDK (4.5.0)

https://developer.leapmotion.com/unity#5436356

The leap motion SDK exposes some unity events for some gestures, eg: left hand opened, right hand opened, the Animation's methods are invoked when those events happens. For more details I recommend to play around with the leap sdk.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Animations : MonoBehaviour {
//public GameObject Lava;
bool canRightRotate = false;
bool canLeftRotate = false;
//public GameObject volcan;
void Start () {
//GetComponent<Transform> ();
//Lava.gameObject.SetActive(false);
}
// Update is called once per frame
void Update () {
// Debug.Log (canRightRotate);
if (canRightRotate) {
transform.Rotate (new Vector3 (0f, 0f, 1f));
}
if (canLeftRotate) {
transform.Rotate(new Vector3(0f,0f,-1f) );
}
}
public void rightVolcanRotate()
{
Debug.Log ("rightVolcanRotate()");
canRightRotate = true;
}
public void rightVolcanStop()
{
Debug.Log ("rightVolcanStop()");
canRightRotate = false;
}
public void leftVolcanRotate()
{
canLeftRotate = true;
}
public void leftVolcanStop()
{
canLeftRotate = false;
}
/*
public void ActivateLava()
{
Lava.gameObject.SetActive (true);
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment