Beispiel #1
0
        private void CheckIn()
        {
            if (!isAnIn)
            {
                RaycastHit2D hit = Physics2D.Raycast(left.position, Vector2.up, detectionLine,
                                                     1 << LayerMask.NameToLayer("AN"));
                if (hit.transform != null)
                {
                    isAnIn = true;
                    an     = hit.transform.GetComponent <An>();
                    anMass = an.GetComponent <Rigidbody2D>().mass;
                }
            }

            if (!isPankapuIn)
            {
                RaycastHit2D hit = Physics2D.Raycast(left.position, Vector2.up, detectionLine,
                                                     1 << LayerMask.NameToLayer("Pankapu"));
                if (hit.transform != null)
                {
                    isPankapuIn = true;
                    pankapu     = hit.transform.GetComponent <Pankapu>();
                    pankapuMass = pankapu.GetComponent <Rigidbody2D>().mass;
                }
            }
        }
Beispiel #2
0
 private void CheckOut()
 {
     if (isAnIn)
     {
         RaycastHit2D hit = Physics2D.Raycast(right.position, Vector2.up, detectionLine,
                                              1 << LayerMask.NameToLayer("AN"));
         if (hit.transform != null)
         {
             isAnIn = false;
             an.GetComponent <Rigidbody2D>().mass = anMass;
         }
     }
     if (isPankapuIn)
     {
         RaycastHit2D hit = Physics2D.Raycast(right.position, Vector2.up, detectionLine,
                                              1 << LayerMask.NameToLayer("Pankapu"));
         if (hit.transform != null)
         {
             isPankapuIn = false;
             pankapu.GetComponent <Rigidbody2D>().mass = pankapuMass;
         }
     }
 }