Exemple #1
0
 void Update()
 {
     if (m_Player.transform.position.y - m_Platform.transform.position.y > m_Distance)
     {
         m_CanPush = true;
     }
     else
     {
         m_CanPush = false;
     }
     if (m_PlayerController.GetVelocity() > 0)
     {
         m_CanPush = false;
     }
 }
Exemple #2
0
 //Начало разговора
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         m_PlayerController = collision.GetComponent <NewPlayerController>();
         m_PlayerVelocity   = m_PlayerController.GetVelocity();
         m_Active           = true;
         m_Canvas.gameObject.SetActive(true);
         StartCoroutine(StartDialog());
     }
 }
    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();
            }
        }
    }