Last active
February 2, 2016 13:02
-
-
Save Kwentar/61e3d8a93b73da820815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class MainSphereScript : MonoBehaviour { | |
bool moving = false; | |
int countMovingFrames = 100; //время движения в кадрах | |
int currentCountFrames = 0; | |
bool reverse = false; //флаг прямого/обратного движения | |
void Start () | |
{ | |
KinectManagerScript.OnSwipeUpDown += new KinectManagerScript.SimpleEvent(KinectManagerScript_OnSwipeUpDown); | |
} | |
void KinectManagerScript_OnSwipeUpDown() | |
{ | |
Debug.Log("upDown From listener"); | |
if (!moving) | |
{ | |
moving = true; | |
reverse = false; | |
currentCountFrames = 0; | |
} | |
} | |
void Update () | |
{ | |
if (moving) | |
{ | |
currentCountFrames++; | |
if (currentCountFrames >= countMovingFrames) | |
{ | |
if (!reverse) | |
{ | |
reverse = true; | |
currentCountFrames = 0; | |
} | |
else | |
{ | |
moving = false; | |
} | |
} | |
if(!reverse) | |
transform.Translate(-2* Vector3.up * Time.deltaTime); //прямой ход | |
else | |
transform.Translate(2* Vector3.up * Time.deltaTime); // обратный ход | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment