for some reason my code seems to rotate my x value to a random position anywhere from 140-170
The object always starts at the same rotation but never ends up rotating the same place. does anyone know the problem
{ public float speed;
public float rotate;
public bool newRotate;
public float startTime = 0.3f;
public float continueTime = 0.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.up * Time.deltaTime * Input.GetAxis("Vertical") * speed);
transform.Translate(Vector3.right * Time.deltaTime * Input.GetAxis("Horizontal") * speed);
if (newRotate == false && Input.GetKeyDown(KeyCode.Space))
{
transform.Rotate(Vector3.right * rotate * Time.deltaTime);
newRotate = true;
}
if (newRotate == true && Time.time > continueTime)
{
continueTime = Time.time + startTime;
transform.rotation = new Quaternion(-500, 0, 0, 0);
newRotate = false;
}
}
}