Пример #1
0
    void CheckForPlayerGroundPos()
    {
        RayProp prop = IsGroundHit();

        if (prop != null)
        {
            if (movInputInvoked)
            {
                Vector3 playerMovDir = (transform.position - lastPlayerPos).normalized;
                if (playerMovDir.x != 0 && IsWallHit() == null)
                {
                    playerRot = rotAmt;
                }
            }
            prop = IsSlatedPlatformHit();
            if (prop != null)
            {
                if (Vector2.Angle(Vector2.up, prop.hitInfo.normal) > 0 && !movInputInvoked)
                {
                    playerVel = Vector2.zero;
                    playerRot = 0;
                }
            }
            TakeJumpInput();
        }
        else
        {
            CheckForRotDirAndApplyRot();
            CancelJumpingUp();
        }
    }
Пример #2
0
    private RayProp IsWallHit()
    {
        RayProp prop = IsSideLeftWallHit();

        if (prop != null)
        {
            return(prop);
        }
        prop = IsSideRightWallHit();
        if (prop != null)
        {
            return(prop);
        }
        return(null);
    }
Пример #3
0
 void ProcessJumping()
 {
     if (!onGround)
     {
         if (jumpingUp)
         {
             playerVel = playerVel + (Vector2.up * jumpUpSpeed);
             if (IsCealingHit() != null)
             {
                 CancelJumpingUp();
             }
         }
         else
         {
             playerVel = playerVel + (-Vector2.up * comeDownSpeed);
         }
     }
     else
     {
         RayProp prop = IsSlatedPlatformHit();
         if (prop != null)
         {
             if (Vector2.Angle(Vector2.up, prop.hitInfo.normal) > 0 && !movInputInvoked)
             {
                 playerVel = Vector2.zero;
             }
             else
             {
                 playerVel = playerVel + (-Vector2.up * comeDownSpeed);
             }
         }
         else
         {
             playerVel = playerVel + (-Vector2.up * comeDownSpeed);
         }
     }
 }