Beispiel #1
0
 private void PushPlayer()
 {
     //Debug.Log("Player velocity: " + m_PlayerController.GetVelocity());
     m_Velocity = m_PlayerController.GetVelocity();
     if (m_Velocity > 0 && m_Platform.transform.position.y - m_Player.transform.position.y > m_DownDistance * m_Platform.transform.localScale.y)
     {
         Debug.Log("Down");
         m_PlayerController.SetVelocity(-m_Velocity);
         Sound();
     }
     else if (m_Velocity < 0 && m_Player.transform.position.y - m_Platform.transform.position.y > m_UpDistance * m_Platform.transform.localScale.y)
     {
         Debug.Log("Up");
         if (Mathf.Abs(Mathf.Abs(m_PlayerController.GetVelocity()) - m_PlayerController.GetMaxVelocity()) < 0.001f && m_CanCrash)
         {
             m_AudioSource.clip = m_CrashAudio;
             Sound();
             m_Rigidbody.constraints = RigidbodyConstraints2D.None;
             //m_Rigidbody.SetRotation(15f);
             m_Collider.enabled = false;
             StartCoroutine(DeactivatePlatform());
         }
         else
         {
             Sound();
         }
         m_PlayerController.SetVelocity(m_PushForce);
         //Sound();
         SetBoundY();
     }
     else
     {
         Debug.Log("Middle");
         m_PlayerController.SetVelocity(m_Velocity);
     }
 }