private void SetExcercise(int index)
    {
        int maxExcercises = (int)Excersice.THIRD;

        if (index > maxExcercises)
        {
            index = 0;
        }

        excersice = (Excersice)index;

        secuencePointList.Clear();
        switch (excersice)
        {
        case Excersice.FIRST:
            pointsInExcersice = 2;
            break;

        case Excersice.SECOND:
            pointsInExcersice = 4;
            break;

        case Excersice.THIRD:
            pointsInExcersice = 5;
            break;
        }

        for (int i = 0; i < pointsInExcersice; i++)
        {
            secuencePointList.Add(Vector3.zero);
        }

        point1.rotation = MyQuaternion.Euler(0f, 90f, 0f);
        point2.rotation = MyQuaternion.Euler(0f, 90f, 0f);
    }
Beispiel #2
0
 private void Rotate()
 {
     if (Data.RotationSpeed != 0)
     {
         MyQuaternion rotationToTarget = MyQuaternion.LookRotation(Data.RotationTarget - Data.Position);
         //removeing z axis
         rotationToTarget = MyQuaternion.Euler(rotationToTarget.eulerAngles.x, rotationToTarget.eulerAngles.y, Data.Rotation.eulerAngles.z);
         Data.Rotation    = MyQuaternion.RotateTowards(Data.Rotation, rotationToTarget, Data.RotationSpeed);
     }
 }
    private static void RunTests()
    {
        Debug.Log(new Quaternion(0, 1, 2, 3) * new Quaternion(0, 1, 2, 3));
        Debug.Log(new MyQuaternion(0, 1, 2, 3) * new MyQuaternion(0, 1, 2, 3));

        Debug.Log(Quaternion.AngleAxis(90f, Vector3.forward));
        Debug.Log(MyQuaternion.AngleAxis(90f, Vector3.forward));

        Debug.Log(Quaternion.AngleAxis(75f, Vector3.forward + Vector3.up));
        Debug.Log(MyQuaternion.AngleAxis(75f, Vector3.forward + Vector3.up));

        Debug.Log(Quaternion.Euler(new Vector3(0f, 0f, 45f)));
        Debug.Log(MyQuaternion.Euler(new Vector3(0f, 0f, 45f)));
    }
Beispiel #4
0
        private void Rotate()
        {
            if (TargetToMove != null)
            {
                MyQuaternion rotationToTarget = MyQuaternion.LookRotation(TargetToMove.Position - p.Position);
                //removeing z axis
                rotationToTarget = MyQuaternion.Euler(rotationToTarget.eulerAngles.x, rotationToTarget.eulerAngles.y, zBeforeRotation);

                if (p.Rotation != rotationToTarget)
                {
                    p.Rotation = MyQuaternion.RotateTowards(p.Rotation, rotationToTarget, p.RotationSpeed * TickDeltaTime / 1000f);
                    Console.WriteLine("Ship {0} , rotation {1} target {2} rotation to target {3}", p.Id, p.Rotation.eulerAngles, TargetToMove.Id, rotationToTarget.eulerAngles);
                }
            }
        }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            DoNextExcercise();
        }

        switch (excersice)
        {
        case Excersice.FIRST:
            point1.rotation *= MyQuaternion.Euler(0, angle * Time.deltaTime * speed, 0);

            secuencePointList[1] = point1.forward * 10f;
            break;

        case Excersice.SECOND:
            point1.rotation *= MyQuaternion.Euler(0, angle * Time.deltaTime * speed, 0);

            secuencePointList[1] = point1.forward * 10f;
            secuencePointList[2] = secuencePointList[1] + (Vector3.up * 10f);
            secuencePointList[3] = secuencePointList[2] + (point1.forward * 10f);
            break;

        case Excersice.THIRD:
            point1.rotation *= Quaternion.Euler(0, angle * Time.deltaTime * speed, angle * Time.deltaTime * speed);
            point2.rotation *= Quaternion.Euler(0, -angle * Time.deltaTime * speed, -angle * Time.deltaTime * speed);

            secuencePointList[1] = point1.transform.forward * 10f;
            secuencePointList[2] = secuencePointList[1] + (point1.up * 10f);
            secuencePointList[3] = secuencePointList[2] + (point2.forward * 10f);
            secuencePointList[4] = secuencePointList[3] + (point2.up * 10f);
            break;
        }

        Vector3Debugger.UpdatePositionsSecuence("Secuence", secuencePointList);
    }