I’m using eulerAngles to rotate a platform for my tilt maze game I keep experiencing gimbal lock and I have no idea how to get around it. Here is my code, help would be much appreciated!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tilt : MonoBehaviour {
public Vector3 currentRot;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
currentRot = GetComponent().eulerAngles;
if ((Input.GetAxis (“Horizontal”) >.2) && (currentRot.z <=10 || currentRot.z >=348))
{
transform.Rotate(0, 0, 1);
}
if ((Input.GetAxis (“Horizontal”) <-.2) && (currentRot.z >= 349 || currentRot.z <=11))
{
transform.Rotate(0, 0, -1);
}
if ((Input.GetAxis(“Vertical”) > .2) && (currentRot.x <= 10 || currentRot.x >= 348))
{
transform.Rotate(1, 0, 0);
}
if ((Input.GetAxis(“Vertical”) < -.2) && (currentRot.x >= 349 || currentRot.x <= 11))
{
transform.Rotate(-1, 0, 0);
}
}
}