Topic: Text Alert When Super Meter Is Full

Hello,

I'd like to know how I can have a text alert when the Super Meter (Guage1) is full.

Thank you

Share

Thumbs up Thumbs down

Re: 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.

Share

Thumbs up Thumbs down

Re: Text Alert When Super Meter Is Full

Can you show an example, please? What event will I need to do this?

Share

Thumbs up Thumbs down

Re: Text Alert When Super Meter Is Full

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;
        }        
    }
}

Share

Thumbs up Thumbs down

Re: Text Alert When Super Meter Is Full

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);
        }
    }
}

Share

Thumbs up +1 Thumbs down