void OnTriggerEnter(Collider other) { if(other.tag == "Player" && state == MOVINGSTATE.wait) { state = MOVINGSTATE.start; startTime = Time.time; } }
void Update() { switch(state) { case MOVINGSTATE.start: if((Time.time - startTime) > 1.5) { transform.parent.animation.Play("MovingPlatform"); state = MOVINGSTATE.moving; } break; case MOVINGSTATE.moving: if(!transform.parent.animation.isPlaying) { startTime = Time.time; state = MOVINGSTATE.ended; } break; } }