This has no sense. There should be a solution we don’t know because right now ALL custom NPC spawners in fortnite are useless.
I do have a janky workaround that you can use until they fix this issue that’s by adding a var option verse device in the module itself and set the option verse device to any verse devices you have then when you need to call for a tag in a module just check the verse device and then use that with the FindCreativeObjectsWithTag and it should work
aren’t weak maps saved per server? couldn’t that be used to save a creative_device_base in a normal Verse Device Script and then outside of the verse device, call the weakmap to get a creative_device to use for FindCreativeObjectsWithTag
For example like this:
(post deleted by author)
I am tring to get some devices with that roundabout but it seems imposible:
var MyVariable:weak_map(session,creative_device) = map{}
if(Device:=MyVariable[GetSession()]):
AllCreativeObjects:=Device.FindCreativeObjectsWithTag(helper{})
for(CreativeObjects : AllCreativeObjects):
Print("THE CODE DOES NOT REACH THIS Trying to find tag on object")
if(Helper := mob_behavior_helper[CreativeObjects]):
PrintFatalError("Tag object MaybeMobBehaviourHelper found")
set MaybeMobBehaviourHelper = option{Helper}
set LastSpecialAction = Helper.TotalTime-99
else:
PrintFatalError("Tag object MaybeMobBehaviourHelper not found")
if(Spawner := player_spawner_device[CreativeObjects]):
PrintFatalError("PlayerSpawner device found")
else:
PrintFatalError("Tag object MaybeMobBehaviourHelper not found")
Have you initiated the creative_device in a normal verse device beforehand?
I dont undertand what are you taking about
I also tried this code:
TagDetector : tag_detector = tag_detector{}
AllCreativeObjects:=TagDetector.FindCreativeObjectsWithTag(helper{})
for(CreativeObjects : AllCreativeObjects):
Print("Trying to find tag on object")
if(Helper := mob_behavior_helper[CreativeObjects]):
PrintFatalError("Tag object MaybeMobBehaviourHelper found")
set MaybeMobBehaviourHelper = option{Helper}
set LastSpecialAction = Helper.TotalTime-99
else:
PrintFatalError("Tag object MaybeMobBehaviourHelper not found")
if(Spawner := player_spawner_device[CreativeObjects]):
PrintFatalError("PlayerSpawner device found")
else:
PrintFatalError("Tag object MaybeMobBehaviourHelper not found")
using a tag dummy
ok so in an actual verse device set the MyVariable to a creative_device and then the if(Defvice:=MyVariable[GetSession()]): will succeed hopefully
what is the tag_detector?
Tag detector is a dummy creative_device.
I am using it to access the Players, and it works:
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
tag_detector := 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}")
So, if I can print the num of players using
Print("NUM PLAYERS: {TagDetector.GetPlayspace().GetPlayers().Length}")
Why this does not work:
AllCreativeObjects:=TagDetector.FindCreativeObjectsWithTag(helper{})
for(CreativeObjects : AllCreativeObjects):
Print("THIS IS NOT REACHEABLE Trying to find tag on object")
if(Helper := mob_behavior_helper[CreativeObjects]):
PrintFatalError("Tag object MaybeMobBehaviourHelper found")
set MaybeMobBehaviourHelper = option{Helper}
set LastSpecialAction = Helper.TotalTime-99
else:
PrintFatalError("Tag object MaybeMobBehaviourHelper not found")
if(Spawner := player_spawner_device[CreativeObjects]):
PrintFatalError("PlayerSpawner device found")
else:
PrintFatalError("Tag object MaybeMobBehaviourHelper not found")
About what you said here. I still don´t understand what are you talking about
ok so in an actual verse device set the MyVariable to a creative_device and then the if(Defvice:=MyVariable[GetSession()]): will succeed hopefully
maybe the TagDetector not being placed in the world causes that? maybe having it from an @editable would work?
Tag detector can not be @editable because I am using this in a npc_behaviour . The class is created by a NPC spawn and I can not control, it
try this
beforehand in a device placed in the game eg game_manager do this
var MyVariable:weak_map(session,creative_device_base)= map{}
game_manager := class(creative_device):
@editable YourIslandSettings : experience_settings_device = experience_settings_device{}
OnBegin():void=
if(set MyVariable[GetSession()]=YourIslandSettings){Print("DEVICE HAS BEEN SET")}
then in whatever other script
if(ADevice:=MyVariable[GetSession()]?):
AllCreativeObjects:=ADevice.FindCreativeObjectsWithTag(helper{})
Edited to replace device mentions to the islandsettings device
Ok I managed to solve the problem thanks for your help and code.
I use these like this, using a player_spawner_device, not a creative_device becauese it couldn´t be assigned to the MyVariable:
var MyVariable:weak_map(session,creative_device_base)= map{}
game_manager := class(creative_device):
@editable
PlayerSpawnerDevice : player_spawner_device = player_spawner_device{}
OnBegin<override>()<suspends>:void=
if(set MyVariable[GetSession()]=PlayerSpawnerDevice){Print("DEVICE HAS BEEN SET")}
else:
PrintFatalError("###########Device can not be setcreative_device")
Yea I initially thought I could just use creative_device_base in an editable to just be able to select any kind of device (even the IslandSettings Device) but turns out it can’t so I then edited it to creative_device which limited it to verse devices.
Anyway regardless so were you able to sucessfully get the FindCreativeObjectsWithTag running in the npc behaviour?
Yes. It works but I will full check it tomorrow
Just want to share my support. I use GetCreativeObjectsWithTag() all the time and in most cases it’s not from within creative_device class. Modules, NPC behaviours - that’s where it belongs and should not be forced out. If stuff ain’t broken - don’t fix it.
Unfortunately don’t work, only if Self or class{}.FindCreativeObjectsWithTag for some devices works, I try to use it with others, but it doesn’t make sense changes, make sense to improve the tag usage, some limitations, etc the same idea we have in UE.
Work only inside of a create device class, in custom classes, modules, etc don’t works.
So this will be broken a lot of projects.
Are we able to publish projects with that warnings?
I found a more stableSolution,
@editable IslandSettingsDevice : experience_settings_device = experience_settings_device{}
when making code to bring a creative_device_base on a weak_map it could actually be set to the IslandSettingsDevice since unlike player spawners,switches,whatever other device that you may delete or remove down the line breaking the code. The IslandSettingsDevice (Ussualy) never has any reason to get deleted. Making it a more stable solution in my opinion