How to use Tags in Verse to enable Volume Device elimination on player enter?/How to set up multiple volumes on 1 Verse device?

Hi all,

Verse noob here, and I’m trying to enable Verse Tags with Volume Devices when a player enters a volume. I started by getting the volume to eliminate players without tags, and here is the code:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters}

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level

Elimination_Volume := class(creative_device):

    @editable Volume : volume_device = volume_device{}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        # TODO: Replace this with your code

        Volume.AgentEntersEvent.Subscribe(EliminateVolume)

    EliminateVolume(Agent : agent):void=
        if (Player := player[Agent]):

            if (FortChar := Player.GetFortCharacter[]):
                FortChar.Damage(10000.0)

This works great, but I’d rather not have a Verse device for each volume device I’d like to use to eliminate players. That’s why I’ve been trying to set up tags, and here is what I have:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters}
using { /Verse.org/Simulation/Tags}

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
Elimination_Volume_Tag := class(tag){}

Elimination_Volume := class(creative_device):

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        # TODO: Replace this with your code

        TaggedVolume := GetCreativeObjectsWithTag(Elimination_Volume_Tag{})
        for (FoundObject: TaggedVolume):
            if(Volume := volume_device[FoundObject]):
                Volume.AgentEntersEvent.Subscribe(EliminateVolume)

    EliminateVolume(Agent : agent):void=
        if (Player := player[Agent]):

            if (FortChar := Player.GetFortCharacter[]):
                FortChar.Damage(10000.0)

However, it does not eliminate the player.

I’ve seen a few posts suggesting that tags don’t work with Volume Devices. If that’s the case, I’m also wondering If there’s any other way I could set up my Verse device to contain multiple instances of volumes that all eliminate players upon entry.

Trying to set up an array to handle multiple volumes in 1 verse device, but can’t figure out how why I get an error on AgentEntersEvent.

Screenshot 2024-09-25 123307

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters}

Elimination_Volume := class(creative_device):

@editable
TargetVolume:[]volume_device = array{}


# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
    # TODO: Replace this with your code

    TargetVolume.AgentEntersEvent.Subscribe(EliminateVolume)

EliminateVolume(Agent : agent):void=
    if (Player := player[Agent]):

        if (FortChar := Player.GetFortCharacter[]):
            FortChar.Damage(10000.0)

Hey @Reeyawn,

Have you tried using mutator devices instead of volume devices?

if not, try and let me know if it works. If it doesn’t, I’ll help figure this out with you.

1 Like

Thanks for the reply!

I’ll definitely try the same approach with mutator zones, but I wanted to use volume devices because I read somewhere that they use a lot less memory than mutator zones and damage volumes. The damage volume does exactly what I want the volume device to do; otherwise, I’d just use the damage volume. However, I’m creating a deathrun map and plan to have hundreds of these volumes.

So, do you think it’s worth using Verse and volume devices to eliminate the player in an effort to reduce memory usage, or should I stick to mutator zones like you suggested? Or would it just be easier to go ahead with damage volumes? Thanks again for you help!

So anytime you have the opportunity to reduce memory usage on your maps, you’re going to want to attempt that approach, always. However, perfectionism can get in the way of real progress. I fall into this trap often myself. If you have to create a “Janky” mechanic with high memory usage in order to bring your idea to life, just do it. Then we can always come back later and tweak things here and there to bring down memory usage.

That’s a good point. And since I have working volume devices that eliminate the player, I’ll just continue with those for now even though I have to add another verse device for each volume device. But do you think you could help me figure out how to set up an array for volume devices to my code if that’s the best way to achieve multiple instances in one device?

Yeah I can help you with the array. I’m not the best at verse which is why I’m on the dev forums trying to help people. You learn a lot faster by helping others <3

Soo… I’ll write a snippet of what I would assume the array would look for after your devices are tagged.

Full disclosure I put this together in about 5-10 minutes half asleep and I didn’t even test it lol. But I believe this should work… It will also give you a good idea of where to start if it doesn’t.

#Imports
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Random}
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation/Tags }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
tags
volume_area := class(tag){}
#GameManager
GM := class(creative_device):

#GameStart
OnBegin():void=

 #Initiation of devices
  InitVolumes()

volume Device
InitVolumes():void=
Volumes:= GetCreativeObjectsWithTag(volume_area{})
for (Obj : Volumes):
if (Volume:= volume_device[Obj]):
Volume.AgentEntersEvent.Subscribe(OnPlayerEntered)

OnPlayerEntered(Agent:agent):void=
   if (Player := player[Agent]):
       Print("Player Entered Area, Killing player...") 
       KillPlayer(Player)


KillPlayer(Player:player):void=
   if:
       Agent := agent[Player]
       Fort := Agent.GetFortCharacter[]
   then:
       Fort.Damage(10000.0)
1 Like

Thanks a bunch! I’ll test it out and get back to you if I have any other questions or it’s not working as intended.

1 Like

Okay, so I’m getting an error here:
Screenshot 2024-09-28 123724


Does that have to do with the indentation of these lines?

InitVolumes():void=
Volumes:= GetCreativeObjectsWithTag(volume_area{})
for (Obj : Volumes):
if (Volumes:= volume_device[Obj]):
Volumes.AgentEntersEvent.Subscribe(OnPlayerEntered)

I have tried indenting, but nothing I’ve tried so far has gotten rid of the error.

Okay did a bit more troubleshooting lol, but no errors with this:

InitVolumes() : void=
    TaggedVolumes := GetCreativeObjectsWithTag(volume_area{})
    for (Obj : TaggedVolumes):
        if (Volumes := volume_device[Obj]):
            Volumes.AgentEntersEvent.Subscribe(OnPlayerEntered)

Hopefully that’s correct indentation and then I was also getting ambiguous identifier with volumes so I just changed the first couple references to TaggedVolumes like in my original code. I haven’t tested to see if it eliminates the player but fingers crossed.

Okay, whenever I build the verse code it’s showing errors for the other OnBegin() sections in my other verse files. I don’t know enough about specifiers and attributes, but I’ve tried adding <overrides> and <suspends> to the elimination volume like my other files have, but I get an error that reads: This function does not override a function but has an <override> attribute. Would you know what to do about that?

Hey, yeah i just saw all the errors. Not writing code before my coffee anymore. Got a new code for you, testing now…will get back to you soon.

1 Like

I do remember reading somewhere that tags dont work with volume devices so if that becomes the case im going to try and find a workaround that possibily conserves some memory

1 Like

@Reeyawn

Okay, here you go. This is the fix.

#Imports
 using { /Fortnite.com/Devices }
 using { /Verse.org/Simulation }
 using { /Verse.org/Random}
 using { /Fortnite.com/Characters }
 using { /Fortnite.com/Game }
 using { /Verse.org/Simulation/Tags }
 using { /UnrealEngine.com/Temporary/Diagnostics }
 using { /UnrealEngine.com/Temporary/SpatialMath }

#Tags (Don't work for volume device, DO NOT USE)
 ### volume_area := class(tag){} ###
#GameManager
 Volume_Devices := class(creative_device):

  #Arrays
   @editable
   volume_devices : []volume_device = array{}

#GameStart
  OnBegin<override>()<suspends>:void=
    #Initiation of Volume Devices
     InitVolumes()

 #Init
  InitVolumes():void=
    Volumes:= volume_devices
    for (Obj : Volumes):
        if (Volume:= volume_device[Obj]):
            Volume.AgentEntersEvent.Subscribe(OnPlayerEntered)

 #Initiates Kill Player when player enteres volume device
  OnPlayerEntered(Agent:agent):void=
   if (Player := player[Agent]):
       Print("Player Entered Area, Killing player...") 
       KillPlayer(Player)

 #Kill Player Function
  KillPlayer(Player:player):void=
   if:
       Agent := agent[Player]
       Fort := Agent.GetFortCharacter[]
   then:
       Fort.Damage(10000.0)

Just make sure you are adding the volume devices in the game manager details.

And hit that “resolved” button if it works :purple_heart:

1 Like

It works great! Thanks again for all of your help!

1 Like