private void Update() { switch (state) { case PullBackState.Default: break; case PullBackState.Retract: transform.position += Vector3.up * speed * Time.deltaTime; if (transform.position.y > startPosition.y) { state = PullBackState.Default; } break; case PullBackState.Extend: transform.position += Vector3.down * speed * Time.deltaTime; if (transform.position.y < startPosition.y - maxYShift * Screen.height) { state = PullBackState.Default; } break; default: break; } }
public void Extend() { state = PullBackState.Extend; }
public void Retract() { state = PullBackState.Retract; }