【UEFN Question】How to execute TriggerEvent for trigger device array?

I am currently creating a kind of card game and have a question about how to use TriggeredEvents function of a trigger_device array.

I am trying to place multiple trigger devices (card static mesh assigned) on the level and handle them in a trigger_device type array as shown in the Verse code below.

The specifications of the game are

1, Read out each question

2, If each trigger device (= card mesh) is shot during the reading, judge wheter this card is correct one or not.

I would like to implement this process in Verse code.

However, when the judge prosess is implemented in a For statement (a loop that reads out all questions), I cannot use TriggerEvent function in it because the trigger devices are set in the trigger_device array. (TriggerEvent is not member of the array)

The point is that I would like to execute the judge process in For statement when each of the trigger devices on the level is shot, so how should I execute TriggerEvent? I would like to know if you know how to execute.

Thank you,

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/UI }
using { /Verse.org/Colors }

<Class name> := class(creative_device):
# Questions array read out
var Reading: []string = array{<Question Text>}
# Trigger Devices in the level
@editable
TriggerCard : []trigger_device = array{}

OnBegin<override>()<suspends>:void=
# Start Game
Sleep(3.0)
# Each Question is read out
      for(Index := 0..Reading.Length-1):
            if (Element := Reading[Indexi]):
            # Process: Question is displayed
            <Process...>
            # 【Question】When each trigger device is shot, TriggerEvent function is execurted - This "TriggerCard" causes Error because TrigerEvent is not member of trigger_device array
            TriggerCard.TriggeredEvent.Subscribe(OnTriggeredEvent)
OnTriggeredEvent<private>(Readings : string)<suspends> : void =
# Process: Judge whether the Card is correct one or not

TriggerCard is just the name of the array you wold have to iterate through the array and set a Subscribe listener for each element of the array

for(Index := 0..TriggerCard.Length):
    TriggerCard[Index].TriggeredEvent.Subscribe(OnTriggeredEvent)
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.