I’m creating a VR environment, and I need to set up a button on a control panel that will activate an event (fan spinning) on another blueprint. I’ve attached screenshots of my control panel blueprint with a box collision for the on/off switch, and the fan spin up blueprint. Anyone know the best way of getting these two to talk to each other? Screenshots and details would be appreciated, I’m fairly useless with blueprints
The best idea for this situation is generating an event when actor or some component hits on the collision box component;
Casting from Other Actor to your specific class is just programming idiom casting happens on runtime base-derived class inheritance checking.
Also there is another ways to communication with blueprints like [Event Dispathcers][2], [Blueprint Interfaces][3] and making as a public and setting that variable after put actor into the game world.
And most tricky one is using of Get All Actors of Class node returns arrays of references regarding to specified class. This method is not effective for large countable objects in the game world. This call iterates all of game objects in the world may cause that performance issues.
Khubur is correct, cast to other actor and pull out a custom event.
This is how I do it in Widget when a button is pressed
I store my Dealer as a Variable as there is a lot of talking between the widget and the BP.
Then when the ‘Collect’ Button is pressed, I get the dealer and run the ‘Collect’ Event within the dealer.
Then in the ‘Dealer’ the ‘Collect’ event runs.
To make a custom event, Right click and search customer event. I use custom events within the same BP to reduce the spaghetti lines everywhere. As you can see here with the ‘Check_If_Enough_Wood’ custom event loop I have running on a 5 sec delay.
I would do as suggested above and look into Blueprint Interfaces, as this may help with overlap if you have 20 BP fans out there, the overlap will know which fan to turn on and off.
I explained BP Interfaces here:
Regards
That is correct solution too. Using of Get All Actors of Class node is not cost friendly solution because this node iterates all of actors currently referenced in the world. Iterates the all objects even with getting zero index reference.
THIS WILL HELP, I AM STILL NOT AWARE IF YOU CAN CONTROL MORE THAN 1 BLUEPRINT FROM 1 SOURCE BLUEPRINT BUT I WILL TRY TO FIND OUT AND WILL ADD A COMMENT
If you want to control more than one blueprint with one triggering blueprint you have to add more variables - same type the desired to control blueprint name - then must give it a different name of course for example Name2, !!! Dont put same one blueprint twice in the triggering one !!! - crash