void Update() { if (m_Active) { if (Input.GetMouseButtonDown(0)) { if (m_Writing) { StopAllCoroutines(); m_Writing = false; m_PhraseText.text = m_Phrase; } else { if (m_PhrasesQueue.Count != 0) { m_Phrase = m_PhrasesQueue.Dequeue(); StartCoroutine(WritePhrase(m_Phrase)); } else { StartCoroutine(EndDialog()); m_PlayerController.SetVelocity(-m_PlayerVelocity); m_PlayerController.SetCanMove(true); GetComponent <BoxCollider2D>().enabled = false; m_Active = false; } } } } }
private void PushPlayer() { //Debug.Log("Player velocity: " + m_PlayerController.GetVelocity()); m_PushForce = Mathf.Abs(m_PlayerController.GetVelocity()); //m_PlayerRigidbody.velocity = new Vector2(0, m_PushForce); m_PlayerController.SetVelocity(m_PushForce); SetBoundY(); }
private void OnCollisionStay2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { float bound = m_PlayerController.GetBoundY(); if (m_Platform.transform.position.y - m_Player.transform.position.y < m_DownDistance * m_Platform.transform.localScale.y && m_Player.transform.position.y - m_Platform.transform.position.y < m_UpDistance * m_Platform.transform.localScale.y && Mathf.Abs(bound - m_Player.transform.position.y) > 0.001f) { m_Velocity = m_PlayerController.GetVelocity(); Debug.Log("Stay"); m_PlayerController.SetVelocity(m_Velocity); } else { PushPlayer(); } } }