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 → Source Coding → Text Alert When Super Meter Is Full
All you need to to is have a referance to the image component.
Then check if fill amount is 1 (full).
Then execute the code you need.
Can you show an example, please? What event will I need to do this?
this is what I did:
public static void FireGaugeChange(int targetGauge, Fix64 newValue, ControlsScript player){
OnGaugeUpdate?.Invoke(targetGauge, (float)newValue, player);
SuperIsReady();
}
// Define boolean flag variables to keep track of whether the alerts have been fired
private static bool isP1SuperReadyAlertFired = false;
private static bool isP2SuperReadyAlertFired = false;
// Modify the SuperIsReady method to check both players and their flag variables
public static void SuperIsReady()
{
if (UFE.gameMode != GameMode.TrainingRoom && UFE.gameMode != GameMode.ChallengeMode)
{
if (!isP1SuperReadyAlertFired && UFE.p1ControlsScript.currentGaugesPoints[0] == UFE.p1ControlsScript.myInfo.maxGaugePoints)
{
// Fire the alert for player 1 and set its flag variable to true
UFE.FireAlert("Super Is Ready", UFE.p1ControlsScript);
isP1SuperReadyAlertFired = true;
}
if (isP1SuperReadyAlertFired && UFE.p1ControlsScript.currentGaugesPoints[0] != UFE.p1ControlsScript.myInfo.maxGaugePoints)
{
isP1SuperReadyAlertFired = false;
}
if (!isP2SuperReadyAlertFired && UFE.p2ControlsScript.currentGaugesPoints[0] == UFE.p2ControlsScript.myInfo.maxGaugePoints)
{
// Fire the alert for player 2 and set its flag variable to true
UFE.FireAlert("Super Is Ready", UFE.p2ControlsScript);
isP2SuperReadyAlertFired = true;
}
if (isP2SuperReadyAlertFired && UFE.p2ControlsScript.currentGaugesPoints[0] != UFE.p2ControlsScript.myInfo.maxGaugePoints)
{
isP2SuperReadyAlertFired = false;
}
}
}
That looks fine.
You can also do something like this.
using UnityEngine;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
{
[SerializeField]
private Image image;
[SerializeField]
private GameObject alertGameObject;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
SetAlertGameObject();
}
private void SetAlertGameObject()
{
if (image == null
|| alertGameObject == null) return;
if (image.fillAmount >= 1)
{
alertGameObject.SetActive(true);
}
else
{
alertGameObject.SetActive(false);
}
}
}
Universal Fighting Engine Forum → Source Coding → Text Alert When Super Meter Is Full
Powered by PunBB, supported by Informer Technologies, Inc.