private void OnTriggerStay2D(Collider2D collision) { if (collision.attachedRigidbody != null) { if (Vector2.Distance(transform.position, collision.transform.position) < collision.transform.lossyScale.magnitude) { SaveScore.Invoke(); SceneManager.LoadScene(nextLevel); } collision.transform.up = Vector2.Lerp(collision.transform.up, CalculateSuction(transform.position, collision.transform), Time.deltaTime * 100); } }
// Update is called once per frame void Update() { if (m_rigidbody.velocity.magnitude > 0.01) { m_rigidbody.velocity = transform.up * m_rigidbody.velocity.magnitude - transform.up * speedLoss * Time.deltaTime; } if (fuel == 0) { if (Mathf.Abs(m_rigidbody.velocity.magnitude - lastVelocityMagnitude) < 0.01 * Time.deltaTime) { SaveScore.Invoke(); SceneManager.LoadScene(lostScene); } lastVelocityMagnitude = m_rigidbody.velocity.magnitude; } }