Ok; but I need to update a lot.
So the best way would be to put all the objects of a class in an Array and loop through them?
=xu1a9jFZc7g
(so instead of the “get all actors” like in the video. If I use my own array (filling it while building the level) this would be the preferred way of doing it)
Another option would be to pull the variable from the sun using a “Cast To”. In each blueprint you then just have something that fires every 15 minutes to pull the variable.
Would save you having to get each object in the level you want to update.
Ok, thanks;
would that be wise from a performance point of view ?
a clock of the “tick event” in every BP; to pull the variables (of several other BP’s)
Ok, thanks;
would that be wise from a performance point of view ?
a clock of the “tick event” in every BP; to pull the variables (of several other BP’s)
[/QUOTE]
I will suggest using timeline for each object. I think if the interval is same you need not listen to the event you can set the timeline to each actor and perform the update after the set interval.
Though the drawback is you might have to change the timeline value for each of the object if you want to set it to different interval. Link for timeline.
or add this timeline in level blueprint as unreal engine documentation suggests to use level blueprints
“A Level Blueprint is a specialized type of Blueprint that acts as a level-wide global event graph.”
There are a couple ways I think you could do this. You’ll probably want to check out the “Blueprint Communication Methods” section of this page: Specialized Node Groups | Unreal Engine Documentation (I think there are also some demo maps/videos, but not sure off the top of my head).
One way is the aforementioned looping over a collection of actors manually and acting on them that way. You could construct that list in different ways (looping through actors up front and putting them in a list, having actors register themselves into a list as they begin play, etc.). If you needed different types of actors to be usable, you could also look into blueprint interfaces and use them in conjuction: Implementing Blueprint Interfaces | Unreal Engine Documentation.
However, another way you could do this seems much closer to what you’re used to. I actually had to just try this out myself because I’ve not used it yet (I live mostly in C++, so this was a fun excuse to learn!): Event Dispatchers | Unreal Engine Documentation
To try out your example, here’s what I basically did:
Created a blueprint that represented the sun.
Made the sun easily globally accessible to other blueprints.
There are various ways to do this. I assumed in this example that the sun was an important gameplay element that there was probably only one of, so I actually spawned it and stored a variable reference to it inside my GameMode’s blueprint. Note this wouldn’t be accessible to clients in a networked game (would probably want it in the GameState for networked play).
Added a float variable to the sun blueprint to represent current temperature.
Added an event dispatcher to the sun blueprint that will be fired every time the sun should broadcast a temperature update.
Added a float input to the event dispatcher representing temperature.
Hooked up a timer to call a function that would update the sun’s temperature every second inside the sun’s blueprint.
Made the update function just constantly add to the sun’s temperature (getting hot in here!). In each update, it also calls the event dispatcher so any listeners will get the update.
To call the dispatcher, just drag it from the variable pane into the event graph and you’ll get a context menu:
Created another blueprint that would act as a listener for the sun updates. I cleverly called it SunListener! So creative!
Hooked the blueprint up to be a listener to the sun’s event dispatcher by:
Accessing the game mode during BeginPlay in the listener’s blueprint, casting it to my custom GameMode blueprint, and then accessing the sun variable stored there.
Pulling off of the sun variable node and selecting the corresponding Assign function.
Hooking up whatever I wanted for the auto-generated event from the Assign function. In my case, I just made it output the name of the actor and the temperature it received to the screen so I could see it was working.
Placed some of the listener actors in the world, ran the game to see what happened…and VOILA!
Hope this helps! I’m definitely not a blueprint expert, so there may still be some other better ways to do this too!
As far as I can tell I did not put it in the Construction Tab of the listner object
(or did you mean the GameObject; I only put in the Ref to the SunObject)
But maybe I’m missing something with this “GameObject”
Uh oh! Ok, I’ll try to get someone from the blueprints team to come in here and make sure I didn’t steer you wrong! In the meanwhile, maybe there’s some diagnostic stuff we can do to see what’s going on:
Do you have any more information about the crash you remember? Logs? (I’ll see if someone can track down the report)
What does the construction script of the Shape_Cube look like?
How are you setting up the value of the sun ref variable in the game mode?
Which version are you on? I made mine at home yesterday on 4.2. Just want to make sure there isn’t a chance of some bug in a different version.
Apologies for the difficulties and hopefully we can figure out what’s going wrong, or if I accidentally misled you!