Pages 1
Universal Fighting Engine Forum We are no longer using the forum to answer questions due to bot attacks. Please use our discord instead: https://discord.gg/hGMZhF7 |
You are not logged in. Please login or register.
Universal Fighting Engine Forum → General → I want to make different blocking ooption
UFE only allows one input to cause blocking at the time of this post.
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;
}
}
Universal Fighting Engine Forum → General → I want to make different blocking ooption
Powered by PunBB, supported by Informer Technologies, Inc.