I’m very new to BP and I’m using UE4 for research purposes.
In my project,in which i’m using VR headset, i show to the partecipant an avatar walking towards him. He has to press a button to make it disappear, after some delay another avatar will be spawned in the initial position of the first avatar doing the same action and so on. I have set this up in the levelBP which i show you. I’m using “switch on Int” node since i’d like to create a sequence and to pass to next step of the sequence each time the partecipant press “R”. It doesn’t seem to work, probably because there is no progression in the input integer requested by the switch on Int node. Could you please suggest me how to solve this problem or indicate another way to accomplish that? Thanks
I don’t really understand how your All Actors of Class array is connected to the Destroy Actor node and why the compiler is fine with that. Normally a ForEach loop would be required there.
Next, I’d better promote the spawned actor to variable and use that to destroy the actor instead of Get All Actors Of Class, but basically that would do the same, maybe with less resources.
Third and the most important, you’re using ForLoop, therefore you do both actions every time you press R. If you only have 2 different actors, try using FlipFlop instead of ForLoop and Switch, if more, try MultiGate that resets after the last pin is executed.
Thanks for your help! It seems to be working using MultiGate node (bp1.png). I’m just curious to know why did u say that it shouldn’t be working with the All Actor of Class array connected to the Destroy Actor node.
Moreover, i’d like to ask you something else, if you can help me, otherwise i’d open a new topic. When participant press the button i would also need to get the distance from the position of the avatar and the position of the camera on which i’ ve set the participant’ s point of view. Any suggestion on that?
Anyway thank you for your help!!
- When you Get All Actors of Class you get an Array of actors. And Destroy applies to one actor. You can see that even the pins look different. That’s why it surprised me how they work with each other. Maybe there are certain exceptions though.
- There’s a special node for that called Get Distance To =)
- P.S. Don’t forget to reset the MultiGate if you want to cycle through the actors again.