So say I want to have an actor that when pickaxed by a player, it spawns a vfx on the button’s position. If the player sees another player break the actor, it shouldn’t affect where it spawns, it should spawn in the actor position. Breakable actors are multiple and in random positions in the map. If two actors are broken simultaneously, they both spawn a vfx.
Trouble is, we can’t find a way to reference a component or an attached actor in verse, and we don’t want to have a sequencer per actor because the breakable actors are a lot.
I think I understand what you are trying to do, I believe you wish to spawn an actor at the location of a creative_prop when it is destroyed. If there was an event that gets called when a prop is disposed for ex: PropDisposedEvent() then this would be as easy as subscribing to the event and using the subscribed function to spawn your VFX at the props location. I thought of a way it can be done using map{} and Verse Tags to keep track of the props. Any prop you wish to have monitored can be registered by adding a Verse Tag to it that matches the tag in the Verse example to follow. Keep in mind these loops are pretty intensive computationally.
[Edit]I am having an issue with the forum sites reply editor, I had to omit a Code Block, so if you are wondering why some of the Verse is not Code Block formatted that is why.
#Track Creative_Props and perform an action when disposed()
#Hopefully in the future there will be a onDisposedEvent() that can be subscribed to instead
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Simulation/Tags }
using { /UnrealEngine.com/Temporary/SpatialMath }
TaggedProp := class(tag){}
# A Verse-authored creative device that can be placed in a level
PropMonitoringDevice := class(creative_device):
var ValidProps : [int]creative_prop := map{}
var PropTransforms : [int]transform := map{}
Have to omit the next code block or forum editor freezes
Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
# TODO: Replace this with your code
#Init ValidProps with tagged props
TaggedProps := GetCreativeObjectsWithTag(TaggedProp{})
#Test that something was returned
if (TaggedPropTest := creative_prop[TaggedProps[0]]):
for:
PropIndex -> TempTaggedProp : TaggedProps
CurrentProp := creative_prop[TempTaggedProp]
do:
#This can be expensive, maybe consider other options.
if(set ValidProps[PropIndex] = CurrentProp):
if(set PropTransforms[PropIndex] = CurrentProp.GetTransform()):
Print("Initialized Prop")
#Loop to check for a change in array state (Prop Disposed Event)
loop:
#used for rebuilding arrays
var tempValidProps : [int]creative_prop = map{}
var tempTransforms : [int]transform = map{}
for:
PropIndex -> TempProp : ValidProps
do:
#Failable conditonal statement can be used to detect if the prop is still valid
if(TempProp.IsValid[]):
Print("Still Exists")
if(set tempValidProps[PropIndex] = TempProp):
if(set tempTransforms[PropIndex] = TempProp.GetTransform()):
#Skip without printing again for no reason
NOP:=0;
else:
Print("Not Valid")
if(DestroyedPropTransform := PropTransforms[PropIndex]):
OnPropBroken(DestroyedPropTransform)
#Reasign our original arrays
set ValidProps = tempValidProps
set PropTransforms = tempTransforms
#Arbitrary Sleep
Sleep(1.0)
OnPropBroken(PropLocation : transform) : void =
#Spawn FX at transform location
#Your code for spawning an VFX
Print("VFX Spawned @: X: {PropLocation.Translation.X} Y: {PropLocation.Translation.Y} Z: {PropLocation.Translation.Z}")
I’m not sure what you mean by “attached to”, but what actually is your “actor” a type of? If it’s a breakable actor, then I assume you’re using a prop_manipulator_device - or maybe should be. Since it has HarvestingEvent, DamagedEvent, and DestroyedEvent. You can just subscribe to these events. And to get the location of the prop_manipulator, just use the usual GetTransform() method on itself.
Its a blueprint actor “building prop”. If there is a static mesh as a component to it, was wondering how I can reference that since tags don’t work with non-BP building props.
I’m a little confused by your last statement, is it actually a Prop or is it just a static mesh? If it is a Prop then you should be able to just add a Verse_Tag to it in the details pane by clicking the green “+” button.
[Edit] Perhaps you mean you have a Building Prop and you attached a Static Mesh to a Socket that the original Prop has? If so you can create a BluePrint Class and attach the static Mesh to it to make it a Prop, then attach that to the Socket of the original building Prop.
Aologies if it’s a bit too off-topic or hijacky but I feel like terminology is super important here, since we all have different backgrounds. If someone could help me clarify a couple things I would appreciate it a lot. (Background: I am very new to Fortnite and Creative, but I know a bit about UE and am quickly learning Verse).
This might seem pedantic but I really think it’s important for everyone, because we have three worlds converging here - the Unreal Editor, Fortnite Creative, and the new UEFN stuff - and we have access to a lot of things in UEFN that do not work correctly (or should be hidden in the Fortnite-ized Unreal Editor) but are TODO by Epic.
Is it even possible to have an “Actor” in Fortnite? It seems no, an Actor is a UE thing that UEFN does not deal at all with yet. So what do people mean if they say “Actor” - a “creative_prop” probably? Or am I mistaken?
What actually is “a component of” something? Is one referring to any Instance (in the Outliner) that is a child of another Instance, or by component do they mean e.g. the StaticMesh part of a creative_prop Blueprint?
VerseTags seem nifty but what’s wrong with making your destroyable props all prop_manipulator_device? Does it not work as intended, can’t figure it out, or didn’t occur to you? Generally speaking, games will perform better if you re-use existing message systems rather than rolling your own system - in this case you could subscribe to all those events and have a more concise codebase. Or is there something I’m missing?
Again, apologies if pedantic - but these are genuine questions, I’m very keen to be less of a Fortnite newb
Regardless, let us know how you go - sharing your results would be appreciated by many
Much appreciated! I have a bit of a follow up, I actually did hunt around in the editor for these terms right after I posted that (heh) and I think I’ve figured this out:
An Actor is anything that can be an Instance in the world, I.e. placed in the Outliner. Looking at the “New Blueprint” screen, seems the case - Actor is just the parent type for any Content/Asset that can be Instanced (placed in the world).
After reading what you wrote and what Nman_Pkr said re: Adding Components, I get it - I can see it’s for building composite Actors basically.
Oh that’s a shame. I’ve noticed all kinds of little weird performance/sync issues myself, and you just gave me the hint that it could be because of some kind of Device > Verse latency - similar to that problem.
Cheers!
I’ll have to look more into Components and such, because right now I have a bunch of child actors under a “DummyProp” root Actor. Since these children (they consist of other dummy props with meshes, and also a few zones and sentry devices) are always part of that root Actor, it’d make sense to convert them to components and make the Prop not just an empty DummyProp, hey? Like, once I’m finished building this “Actor” and want to start duplicating it…
…sounds like a decent workflow to me, if I’ve understood that correctly
Apologies again for the digression haha, and thanks.
Well nevermind about the building Actors stuff, I have messed around a bit but need to learn more. Seems what I was thinking - making a “template” - is not really possible right now. But copy/pasting works fine, haha.
So, back to the issue… if you want to “get an actor” (instance?) in the world, there are only two ways I know of:
By finding it with Tags that you’ve already attached, or:
By getting it from an Event that it triggered
Unless there’s more that I missed, getting the reference to a specific component seems not possible. And that’s probably intentional. The actor’s components should be a black-box, relative to other actors. Actors talk to other Actors, yeah - but in order to talk to Actor Components, only the “owning” actor can do that. Because that’s all implementation details specific to the Actor. It’s an OOP thing, encapsulation.
So, attached actors… as in Instances that are Children of another Actor? Well, sure - but I only know of the two ways above to get a reference to something at runtime. You need to either give it a Verse tag, or have it trigger an Event (if an Event can even be triggered for the actor).
Feel free to share some more about what you’re actually trying to do, maybe there are alternative approaches - but yeah, I don’t think there’s a way to simply “get an actor” at any time you want - it has to be at those points where UE <> Verse cross the boundary (i.e. Events and Tag searches) for performance/latency reasons. Probably also the same reason why tags are just tags and can’t have values, and also can’t be changed at runtime - it’s likely just the nature of Verse being compiled into UE stuff rather than literally being interpreted at runtime.
Want to clarify this video doesn’t work anymore. You have to instead define a template folder from editor preferences, and then paste the project file in that template, then remove its bindings (at the bottom of the uefn project file, only where you see the code-like format, leave all syntax as is)