Hi,
So I posted a question yesterday that was similar, but it lead onto a different issue. So now I’m posting this issue as a separate question.
I’m trying to make it so when my object rotates, something happens once. Which is easy.
What I can’t seem to figure out so far is how to revert back to the original settings after the object has stopped so that when it starts moving again, something again can happen, only once. In this case that something is the debug log “MOVING”.
I’d like for the “MOVING” log to only show once for every time the object starts to move after being stationary
Vector3 prevPos;
public bool hasMoved = false;
void Start(){
prevPos = transform.rotation.eulerAngles;
}
void Update ()
{
if ((prevPos != transform.rotation.eulerAngles) && (hasMoved == false))
{
StartCoroutine("CheckForMove");
hasMoved = true;
}
}
IEnumerator CheckForMove(){
{
{
Debug.Log ("MOVING");
prevPos = transform.rotation.eulerAngles;
yield return null;
}
}