Topic: I want to make different blocking ooption

I want to make blocking controls a little bit different. Standing block and crouching block are enabled when you press up and down. But in block option, there is only 1 button, and there is only a Hold Back and Auto Block. Is there a fast way to do it and how?

Share

Thumbs up Thumbs down

Re: I want to make different blocking ooption

UFE only allows one input to cause blocking at the time of this post.
https://i.imgur.com/i7LoUmx.png

Are you wanting to have multiple single button presses cause blocking?
You can use this script I created to have multiple single Button Presses cause blocking.

using UnityEngine;
using UFE3D;

public class CustomBlockingExample : MonoBehaviour
{
    // Warning this sets the potentialBlock variable to true 
    // As long as potentialBlock is set to true the character will block
    // UFE doesnt set potentialBlock to false automatically every frame

    [SerializeField]
    private ButtonPress[] blockButtonPressArray;

    private void FixedUpdate()
    {
        SetBlock(UFE.GetPlayer1ControlsScript());
        SetBlock(UFE.GetPlayer2ControlsScript());
    }

    private void SetBlock(ControlsScript player)
    {
        if (player == null)
        {
            return;
        }

        foreach (ButtonPress buttonPress in player.inputHeldDown.Keys)
        {
            if (IsButtonPressMatch(buttonPress, blockButtonPressArray)
                && player.inputHeldDown[buttonPress] > 0)
            {
                player.potentialBlock = true;
                player.CheckBlocking(true);
            }
        }
    }

    public static bool IsButtonPressMatch(ButtonPress comparing, ButtonPress matching)
    {
        if (comparing == matching)
        {
            return true;
        }

        return false;
    }

    public static bool IsButtonPressMatch(ButtonPress comparing, ButtonPress[] matchingArray)
    {
        if (matchingArray == null)
        {
            return false;
        }

        int length = matchingArray.Length;
        for (int i = 0; i < length; i++)
        {
            if (IsButtonPressMatch(comparing, matchingArray[i]) == false)
            {
                continue;
            }

            return true;
        }

        return false;
    }
}

Share

Thumbs up +1 Thumbs down