I am currently in the middle of adding some functionality to a level I’m making and basically what I’m wanting to do is have multiple objects around the level linked to an event. The objects are going to be little sphere that when clicked on will be destroyed. I am wondering if it is possible to make something like event counter in order to fire off another event. For example say I have 8 destroy actors fire off before I have a specific destroy actor fire off after all the other objects have been destroyed. I am sorry if this sounds confusing but I’m still new to the blue prints system and unsure of how a lot of the systems work.
If you can explain in more detail what is going on in your level it will be easier to give an example to help.
It sounds like you want to set up an integer variable to count the number of actors which have been destroyed, and then a branch node with a condition checking that this variable is >8 with the true branch pointing to another event which would destroy all actors.
That sounds very close to what I am wanting except I want to destroy one particular actor in the scene. The idea for the level is that after clicking on these 8 “switches” which destroys the actors it will link to destroying the other actor, a door in this case.
In your level blueprint, on beginPlay, get all actors of type. So if your spheres you wish to click on are called BP_EventSphereActor, get all those.
In your game state, if you don’t have one I would create one, lets call it “MyGameState” and create a variable of BP_EventSphereActor, let call this “BP_EventSphereActorArray” and make it an array.
Lets create a function in here as well that is called “RemoveSphereFromArray” In the input panel add a variable and make its type BP_EventSphereActor. Call the var SphereToRemove
Drag out a getter for the array and drag off the array and type “removeItem” (I think, I am typing this by memory right now)
Plug in the “SphereToRemove” from the function into the remove item node.
Back in your level blueprint “Get GameState” drag off and “CastToMyGameState” and then “Set BP_EventSphereActorArray”.
Now you have easy access to this array. You could do this from the level BP but I highly suggest a gamestate.
Now, in the BP_EventSphereActor event graph, Whatever event you are using to destroy the actor, before it is destroyed, cast to “MyGameState” again and call the function “RemoveSphereFromArray” and plug a reference to the actor “Self” into it.
Each time you destroy an actor it will be removed from the array.
Now you can check after each time if the “BP_EventSphereActorArray” length is > 0. If so keep going, if not do your magic.
Would it be possible to get some pictures to demonstrate that. I’m still very new to blueprints and I think I know what to do but some area’s confuse me. Like where exactly I set my BP_EventSphere and the array with it.
I’ll do you one better. When I get home from work I’ll throw together a tutorial video covering exactly how to do it. If you let me know what Template you are using and any other little things you are looking/wondering about I might be able to touch on them as well.
Done: here is the link but it is still uploading. https://youtu.be/FCwF9MbkbsY
There are several other ways to do this…this is just a really simple and efficient way. You can place as many objects as you want; not just the three I had. I was just making this quick. You can drag out 100 in one level and 10 in another and it will function the same.
Thank you very much. This will help a lot.