// Update is called once per frame void Update() { if (isStaying) { timeLeft -= Time.deltaTime; } else { if (Mathf.Abs(transform.position.x - location.x) < 0.01f) { transform.position = location; if (isMovingOut) { gameObject.SetActive(false); IsOut?.Invoke(); return; } } else { transform.position = Vector3.Lerp(transform.position, location, speed * Time.deltaTime); } } }
private void Update() { if (_isStaying) { _timeLeft -= Time.deltaTime; if (_timeLeft <= 0) { MoveOut(); } } else { if (Mathf.Abs(transform.position.x - Location.x) < 0.01f) { transform.position = Location; if (_isMovingIn) { Stay(); } if (_isMovingOut) { gameObject.SetActive(false); IsOut?.Invoke(); return; } } else { transform.position = Vector3.Lerp(transform.position, Location, Speed * Time.deltaTime); } } }
private void Update() { _timeLeft -= Time.deltaTime; if (_timeLeft <= 0) { gameObject.SetActive(false); IsOut?.Invoke(); return; } transform.position = Vector3.Lerp(transform.position, transform.position + Vector3.up * 0.2f, Time.deltaTime * 1.5f); }