Initiate "If Loop" From Perception Trigger Activation?

I hope I’m asking this question correctly. I’m new to programming so I apologize in advance.

I have a custom mesh enemy setup using a prop manipulator and would like for the “if loop” function to activate only if a perception trigger device placed in my map…is triggered via direct line of sight.

What I’m trying to accomplish is that if the player enters a room, I want the perception device to trigger and the custom enemies inside that room to then move towards the player and attack them. I have all the MoveTo and attack sequences already setup. As of right now the enemy starts at the beginning of the level.

Do I put “Perception.AgentLooksAtDeviceEvent” somewhere in here?

This was much easier in UE5 with Behavior Trees :sweat_smile:

boss_battle := class(creative_device):
@editable BossMonster : creative_prop = creative_prop{}
@editable BossJumpAttack : cinematic_sequence_device = cinematic_sequence_device{}
@editable BossOverheadAttack : cinematic_sequence_device = cinematic_sequence_device{}
#@editable BossWalk : cinematic_sequence_device = cinematic_sequence_device{}
@editable BossPropManip : prop_manipulator_device = prop_manipulator_device{}
@editable Perception : perception_trigger_device = perception_trigger_device{}

BossBar : health_bar = health_bar{}

# Runs when the device is started in a running game
    #Boss Mechanic GameLoop
    BossBar.Init("Boss Dude", 9001.0)

    AllPlayers := GetPlayspace().GetPlayers()
    if (Player := AllPlayers[0]):