I am trying to hide many actors at a time in the game by pressing “5” but the game takes a 10 sec lag before hiding any ways of making this faster
For heavy loops it would probably be better to implement it in c++.
You could also use dispatchers. Get all of the actors that need to hide / unhide and bind them to a dispatcher. Then just call the dispatcher to change the visibility of all objects (no loops required)
Can i get psudeo script for better understanding,
like i know about event dispatchers have used them for widget operation but not for hiding actors thankyou so much and i have started project as a blueprint so is it possible to add c++ now ?
You can always convert to c++ (just create any c++ from the editor) but you cant revert it back.
can you guide me through i tried but got confused , i used create c++
class
Create an actor to hold and handle the dispatching event
Create widget to control visibility
Add a bind inside the actors that need to have changed visibility (can be also done in a loop if it’s array or collection)
The dispatcher actor has to be placed in the scene for it to function.
If you want to dynamically assign which actors should be visible then instead of putting the bind inside the actor begin play you can just put it in a function somewhere, you just need a reference to the visibility dispatcher and you can then bind / unbind however you want at run-time.
Before switching to to c++ you can try to assign GetAttachedActors to a variable, and then pass it to SetHiddenInGame.
If you pass a pure function into a for each loop it will be called for every loop element, so basically for every actor in loop you call GetAttachedActors function, which is not super optimal.
Secondly, shouldn’t FlipFlop be placed before the ForLoop? It looks like you call Hide function twice.
Do not use a loop for this amount of actors in blueprints. It will lag if you need to iterate through them manually.
This topic has been moved from International to Programming & Scripting: Blueprint.
When posting, please review the categories to ensure your topic is posted in the most relevant space. Hopefully, this category change will help future devs with a similar question.
Happy developing!
Sorry, and thankyou the website was not letting me post in development section i tried a lot the error popped up saving you cant view this issue lastly i was trying each section and it got posted , sorry for inconvenience caused and will look more into categories next time .
No worries at all! That’s what I’m here for.
If you need any help or have any questions, feel free to @ me!
This worked awesome !! and thank you so much !!!
Sure, I’m with you.
Just wanted to mention the Pure Function - ForEachLoop relation, as it was surprising discovery for me.