Verse: FindCreativeObjectsWithTag should be able to function within modules

Hi everyone,

I’m trying to implement FindCreativeObjectsWithTag because of the deprecation of GetCreativeObjectsWithTag, and I don’t really understand why it has to be tied to a creative_device. The function’s signature looks like this:

(InCreativeDevice:creative_device).FindCreativeObjectsWithTag<public>(Tag:tag)<transacts>:generator(creative_object_interface) = external {}

This way, only instances of creative_device can look for objects by tag, but I was hoping to use it in a module where my code is more functional, not so object-oriented. With GetCreativeObjectsWithTag deprecated, I expected to update my code easily, but now I would need to refactor some things. The fastest solution would be to pass down a parameter with the calling device, but it feels like a dirty workaround (prop drilling comes to my mind).

Is there a reason for needing creative_device here? Would be great if we could use the function without it.

I’m also really sad that GetCreativeObjectsWithTags was deprecated and I can’t get the tag array.

2 Likes

Apparently, it would be because of the future structure of Verse, the previous method being a global method, which means it could be accessed from everywhere (across all game sessions and map levels if I understand correctly)

To me, it would mean that they had two choices upon fetching tagged devices :

  • It should fetch devices from the current level, which means that there’s an unexposed level class that would need to be the method holder instead of the creative_device, but this is what they use to know which level to fetch tagged devices from
  • It should fetch devices across levels in the current session, which means that there is an unexposed session class, even though we have an empty session class already, it seems to be needing a rework, I’m also confused here because fort_playspace seems to do the trick, but maybe it needs a rework too

The first answer seems to make more sense, it’s only speculation though

1 Like

This is severely uncool. What if we are implementing npc_behavior or something and don’t have access to a creative device?

3 Likes

This is a really good example that I’m thinking Epic didn’t think about, well you need to find a way to access any placed creative_device globally from the behavior since you can’t choose a device reference from npc_behaviors, any creative_device editable will construct a new one which cannot be used to fetch tagged devices

1 Like

Which is very perilous, given the gargantuan efforts I have already had to take to avoid concurrency issues.

1 Like

There needs to be a global query thread safe version of this function that does not require a creative device.

1 Like

Me thinks lama is one smart lama. Count down clock until Graeme Bull’s head explodes

2 Likes

I’m not that smart sometimes

It took me a few minutes to figure this out as well. You use it directly in the for loop then cast it to whatever you want separately:

        for (TaggedActor : FindCreativeObjectsWithTag(tagg{})):
            if (TheVerseDevice := verse_device[TaggedActor]):
                 #do what you want here with TheVerseDevice

As far as I can tell you can’t give it multiple tags, though

That only works from inside of a creative_device, which is unfortunately not the issue.

1 Like

(post deleted by author)

Do you know how to use this? I don´t quite understand how to use this function

If you don’t know how to use tags, then you don’t need tags … but to understand them watch the video. The code is essentially the same as long as you use FindCreativeObjectsWithTag from => within a creative device <= … but this whole thing unfortunately leads to a predicament in the area of what the original poster discusses.

I have been using tag since the begining or UEFN. I just don´t understand how to use this specific specific new function.

That video show how to use GetCreativeObjectsWithTag but I don´t undertand how to use the new, as it is use a interface. I need a code example to undertand it

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

# 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
hello_world_device := class(creative_device)
{
    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
    {
        # TODO: Replace this with your code
        #Print("Hello, world!")
        #Print("2 + 2 = {2 + 2}")

        DoNotFollowThisExample()
    }

    DoNotFollowThisExample():void=
    {
        TaggedActors := FindCreativeObjectsWithTag(my_device_tag{})

        for( TaggedActor : TaggedActors )
        {
            # Print("Why, hello there!")
        }
    }
}

The “my_device_tag” thing is your tag. With your name. Which you should already have, or can make like in the video.

Ok the problem was that I can not use the function in a class that is not a creative device. The old functiona did not have this issue. What a mess.

2 Likes

Yes! That is the real problem.

So I have not a very simple question fo Epic. How in the hell I can now find my mob_behavior_helper so my npc_behaviour can detect the players??!?!

They just screwed all the NPC scripts!!!

2 Likes

Yes. What this man just said. Brother, we are now on the same team.