예제 #1
0
    void OnCollisionStay2D(Collision2D collision)
    {
        foreach (ContactPoint2D contact in collision.contacts.DistinctBy(c => c.collider))
        {
            if (contact.normal != moveInput * Vector2.left)
            {
                continue;
            }

            if (wallBumpRepeatTimer < 0)
            {
                wallBumpRepeatTimer = WallBumpRepeatTime;
                WallBumpSource.Play();
            }
        }
    }
예제 #2
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     foreach (ContactPoint2D contact in collision.contacts.DistinctBy(c => c.collider))
     {
         // assumes that all collisions are axis aligned
         if (contact.normal == Vector2.up)
         {
             LandSource.Play();
         }
         else if (contact.normal == Vector2.down)
         {
             CeilingBumpSource.Play();
             fadeOutJumpSource();
         }
         else
         {
             WallBumpSource.Play();
             wallBumpRepeatTimer = WallBumpRepeatTime;
         }
     }
 }