Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.