Exemple #1
0
    private void GetDirectionInputs()
    {
        DebugDirectionalInputs horizontalInput = DebugDirectionalInputs.Neutral;
        DebugDirectionalInputs verticalInput   = DebugDirectionalInputs.Neutral;

        if (Input.GetAxis("PS4LX") >= 1.0f || Input.GetAxis("PS4DX") >= 1.0f)
        {
            horizontalInput = DebugDirectionalInputs.Right;
        }
        else if (Input.GetAxis("PS4LX") <= -1.0f || Input.GetAxis("PS4DX") <= -1.0f)
        {
            horizontalInput = DebugDirectionalInputs.Left;
        }
        else
        {
            horizontalInput = DebugDirectionalInputs.Neutral;
        }

        if (Input.GetAxis("PS4LY") >= 1.0f || Input.GetAxis("PS4DY") >= 1.0f)
        {
            verticalInput = DebugDirectionalInputs.Up;
        }
        else if (Input.GetAxis("PS4LY") <= -1.0f || Input.GetAxis("PS4DY") <= -1.0f)
        {
            verticalInput = DebugDirectionalInputs.Down;
        }
        else
        {
            verticalInput = DebugDirectionalInputs.Neutral;
        }

        MixDirectionalInputs(horizontalInput, verticalInput);
    }
Exemple #2
0
 private void MixDirectionalInputs(DebugDirectionalInputs horizontalInput, DebugDirectionalInputs verticalInput)
 {
     if (horizontalInput == DebugDirectionalInputs.Neutral)
     {
         gamepadInput.dirInput = verticalInput;
     }
     else if (horizontalInput == DebugDirectionalInputs.Left)
     {
         if (verticalInput == DebugDirectionalInputs.Neutral)
         {
             gamepadInput.dirInput = horizontalInput;
         }
         else if (verticalInput == DebugDirectionalInputs.Up)
         {
             gamepadInput.dirInput = DebugDirectionalInputs.UpLeft;
         }
         else
         {
             gamepadInput.dirInput = DebugDirectionalInputs.DownLeft;
         }
     }
     else
     {
         if (verticalInput == DebugDirectionalInputs.Neutral)
         {
             gamepadInput.dirInput = horizontalInput;
         }
         else if (verticalInput == DebugDirectionalInputs.Up)
         {
             gamepadInput.dirInput = DebugDirectionalInputs.UpRight;
         }
         else
         {
             gamepadInput.dirInput = DebugDirectionalInputs.DownRight;
         }
     }
 }