Here is my code which returns false and true at the same time and the pins are shaking, I can’t figure out how to get this to behave.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pin : MonoBehaviour {
//this value is overridden by any change made in the inspector
public float standingThreshold = 3f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
print (name + IsStanding());
}
public bool IsStanding(){
Vector3 rotationInEuler = transform.rotation.eulerAngles;
float tiltInX = Mathf.Abs(rotationInEuler.x);
float tiltInZ = Mathf.Abs(rotationInEuler.z);
//print (tiltInX + " " + tiltInZ);
if (tiltInX < standingThreshold && tiltInZ < standingThreshold) {
return true;
} else {
return false;
}
//return true;
}
}