im trying to implement a system where the player can update one actor and it updates every other actor to be the same.
is there any way to quickly do this other than just use an object reference and a for loop and remake the components piece by piece?
would instances work for this?
Can you describe the situation without using any engine concepts? What kind of scenario is this?
it would actually be easier to describe using engine concepts so ill do that. not totally sure how id describe it otherwise.
basically, i want to make an actor with 10 or so components. i wont know what these components are at runtime, or how many im going to have (it will be grabbed from a json file).
a basic example could be a few static mesh components, procedural mesh components, and some point lights.
The idea is, people could spawn this actor with its specific layout multiple times (maybe 100), then when changes occurred to the original actor, all of them would update to be the same, ideally between frames.
something to the same affect as updating a material; every other place that has this material will get updated too.
If we can imagine these would be blueprints, then the simplest way, would be to get them all to subscribe to an event dispatcher. When the event is triggered, they all just reload their components.
The dispatcher would be from a single ‘controller actor’.
that could work, but i dont know how fast that could be. are spawning components generally lightning fast? assuming that im dealing with around 10 components in the master actor, and i have 100 cloned actors, ill need to update about 1000 components, whether it be spawning them, removing them, or changing their properties. i mainly just want it to be as quick as possible because this may need to happen extremely often (input from a widget slider for example).
Ah, idea…
You might be able to get some leverage using level streaming.
If your actor just exists alone in a level, you could just stream instances of that level. That would be pretty good, I think…
yeah thats what i suspect. i was hoping there was something already built into unreal engine to instance these actors. they are going to be identical in every way other than location.
there is a new thing called light weight actor instance, but i think thats mainly just for spawning premade actors and not spawning stuff at runtime like what im wanting to do
See my edit above ^
hmmm… maybe if im able to make the levels at runtime? idk. im going to have a whole bunch of other stuff in the level so i wont just have the actor cleanly unfortunately.
These are level ‘instances’.
You only need the actor in the level. Everything else can be in your main level.
If the actor is a blueprint, when you stream the instance, it’s going to load itself automatically.
You have tuuts like this
But that’s not quite what I mean.
I’m talking about streaming level instances using blueprint at runtime.
hmm… this is worth exploring thank you.
im just concerned about performance tho. thats gonna be the biggest challenge in my project as its a utility, rather than something like a game; when bad performance gets in the way of your work flow its extremely annoying, especially when that performance gets crippling when you want to make changes at on a very large scale (5000 actors, with 20 components each for example)
I would A/B blueprint reload vs streaming and see what’s going on.
Would be interested to hear…
( in the end, it’s probably going to be C++ )
ill let you know my results. im curious as well, as one person said they were able to spawn about 100 mesh instance components (specifically) in 1ms, which is super impressive, but also not dynamic enough for my use case.
lol. probably yeah ill have to jump into C++.
Yeah, it really depends on exactly what’s happening. If it’s a collection of meshes, you could just make one, and then instance it. That would be quick. But with lights and other stuff, meh…
well, i may be able to get away with emissive textures in my editor, and use real lights in my final build? that could work possibly. not ideal, but may work.
hmm… maybe i can use just meshes after all…
also, while i have you here, do you know of any quick way to get an int from a specific index of numbers?
something like: 5498572
index 3 = 8
i can use this, but its not super performant when im running this 500,000 times. im specifically looking at power, which, if i remember correctly, is very slow.
Much easier to convert to string and use substring?
that would be the easiest way, but i wonder if that’s faster, which is my main concern.
well, thank you for your help anyways. ill take a look at level instances. that may be what im looking for
oh ill give it a go. thank you