예제 #1
0
    void Update()
    {
        if (tMyo.pose == Pose.Fist)
        {
            thrown = true;
            Debug.Log(thrown);
            myoStatus = "Fist";
            //pathsColliders.SetActive(false);
        }
        else
        {
            myoStatus = "Hand relaxed";
            if (thrown)
            {
                float dis = Vector3.Distance(hand.transform.TransformPoint(Vector3.zero), foreArm.transform.TransformPoint(Vector3.zero));
                dis += Vector3.Distance(upperArm.transform.TransformPoint(Vector3.zero), foreArm.transform.TransformPoint(Vector3.zero));
                dis -= Vector3.Distance(hand.transform.TransformPoint(Vector3.zero), upperArm.transform.TransformPoint(Vector3.zero));

                if (dis < distanceLimit)
                {
                    float angle = 0f;
                    if (vectors.Count > 3)
                    {
                        Vector3 a = vectors[vectors.Count - 1] - vectors[vectors.Count - 3];
                        angle = Mathf.Tan(a.y / a.x) * 180 / Mathf.PI;
                    }
                    tangent(shuriken, upperArm.transform.TransformPoint(Vector3.zero), hand.transform.TransformPoint(Vector3.zero), speed, angle);
                    thrown = false;

                    //pathsColliders.SetActive(true);
                }

                vectors.Clear();
            }
            count--;
            if (count == 0)
            {
                count = frameRate;
                vectors.Add(hand.transform.TransformPoint(Vector3.zero));
                if (vectors.Count > 10)
                {
                    vectors.RemoveAt(0);
                }
                if (!thrown)
                {
                    if (vectors.Count > 3)
                    {
                        Koeficijenti.followPath(vectors.ToArray(), sphere, true, pathsColliders);
                    }
                }
            }
        }
    }
예제 #2
0
    void Update()
    {
        count--;
        if (count == 0)
        {
            count = frameRate;

            vectors.Add(leftHand.transform.TransformPoint(Vector3.zero));
            if (vectors.Count > 10)
            {
                vectors.RemoveAt(0);
            }
            if (vectors.Count > 3)
            {
                Koeficijenti.followPath(vectors.ToArray(), sphere, true, pathsColliders);
            }
        }
    }
예제 #3
0
    // Update is called once per frame

    /*
     * Tamarin update za suriken :D
     * void Update () {
     *      count --;
     *      if (count == 0) {
     *              count = frameRate;
     *
     *              if (tMyo.pose == Pose.Fist) {
     *                      pathsColliders.SetActive(false);
     *                      Debug.Log ("STISNUTA");
     *                      vectors.Add (hand.transform.TransformPoint (Vector3.zero));
     *                      thrown = false;
     *                      if (lastPose != Pose.Fist )
     *                              vectors.Clear ();
     *                      //vectors.Clear ();
     *                      //frameRate = 1;
     *              } else {
     *                      //Debug.Log ("PUSTENA");
     *                      if (lastPose == Pose.Fist && thrown == false) {
     *                              Debug.Log ("BACANJE");
     *                              thrown = true;
     *                              lastPose = tMyo.pose;
     *                              if (vectors.Count >= 3) {
     *                                      while (vectors.Count>40)
     *                                              vectors.RemoveAt (0);
     *                                      calculateShurikenPath();
     *                                      //Koeficijenti.calculatePath (vectors.ToArray (), sphere, shuriken, false, pathsColliders);
     *                                      br++;
     *
     *                                      Debug.Log ("baca suriken " + br);
     *                              }
     *                              vectors.Clear ();
     *                              //int x = pathsColliders.transform.childCount;
     *                              //tangent(shuriken, pathsColliders.transform.GetChild(x-5).position, pathsColliders.transform.GetChild(x-2).position, 5f);
     *                              //frameRate = 4;
     *                              pathsColliders.SetActive(true);
     *                      }else{
     *                              vectors.Add(hand.transform.TransformPoint(Vector3.zero));
     *                              if (vectors.Count > 6){
     *                                      vectors.RemoveAt(0);
     *                              }
     *                              if (vectors.Count > 3){
     *                                      Koeficijenti.followPath(vectors.ToArray(), sphere, true, pathsColliders);
     *                              }
     *                      }
     *              }
     *              lastPose = tMyo.pose;
     *      }
     * }*/

    void Update()
    {
        count--;
        if (count == 0)
        {
            count = frameRate;

            vectors.Add(hand.transform.TransformPoint(Vector3.zero));
            if (vectors.Count > 10)
            {
                vectors.RemoveAt(0);
            }
            if (vectors.Count > 3)
            {
                Koeficijenti.followPath(vectors.ToArray(), sphere, true, pathsColliders);
            }

            if (tMyo.pose == Pose.Fist)
            {
                //pathsColliders.SetActive(false);
                count = 1;
                Debug.Log("STISNUTA");
                //vectors.Add (hand.transform.TransformPoint (Vector3.zero));
                thrown = false;
            }
            else
            {
                //Debug.Log ("PUSTENA");
                if (lastPose == Pose.Fist && thrown == false)
                {
                    Debug.Log("BACANJE");
                    thrown   = true;
                    lastPose = tMyo.pose;
                    if (vectors.Count >= 3)
                    {
                        while (vectors.Count > 40)
                        {
                            vectors.RemoveAt(0);
                        }
                        calculateShurikenPathRed();
                        //Koeficijenti.calculatePath (vectors.ToArray (), sphere, shuriken, false, pathsColliders);
                        br++;

                        Debug.Log("baca suriken " + br);
                    }
                    vectors.Clear();
                    //pathsColliders.SetActive(true);
                }
                else
                {
                    /*vectors.Add(hand.transform.TransformPoint(Vector3.zero));
                     * if (vectors.Count > 10){
                     *      vectors.RemoveAt(0);
                     * }
                     * if (vectors.Count > 3){
                     *      Koeficijenti.followPath(vectors.ToArray(), sphere, true, pathsColliders);
                     * }*/
                }
            }
            lastPose = tMyo.pose;
        }
    }