Need Help With Boolean System.

Its the same setup you posted above.

Why not use an enum instead? That graph looks reaaaaly weird to me

Ok so in your first shot there you’re not checking the slot of the item to be destroyed. In the destroyitem function I posted, it took in a reference to an actor, which we then used to get the stored index variable (telling us which slot to free up). The way you have it now it just going to free up the last index used, as you said. Whatever you have going into that Destroy Actor node, you need to get the index off of that, and free up that slot.

In your second screenshot, the Spawned_Eyes event, if the branch comes out false you’re just destroying the object, but you aren’t going back and freeing up that slot again. What i would do is, if that branch comes out false, just call your Event Remove Object, which you’ve already set up to free the appropriate slot and delete the object.

Oh sorry the second shot was the wrong picture. I changed it becuase i uploaded the wrong one. Also i cannot connect the Custom event to the slot index i have the pin on the custom event set as an Actor reference. And Slot index is set as editable and exposed on spawn.

Ok, couple of ways we could handle that then. You could cast that actor reference to the eyes actor, then get the slot index from that. This won’t do very well though if you have a bunch of different objects as you’d have to go through trying to cast the actor to many things until you found the class that you need.

Probably a better way would be to make a new Actor blueprint, and call it something like “SpawnableActor”. Put your index variable in that, instead of eyes. Then you make your eyes blueprint, and every other spawnable object blueprint, a child of this spawnable actor class, so that it inherits that index variable. That way, in your custom event, instead of passing an actor, you can pass in a SpawnableActor, and you’ll be able to access your index no matter what object you spawned.

Ok i did the second option you said and i can connect it now. But i dont really understand this custom event. Where is the function that starts the event and does it take refecence from the spawn actor class? Im trying to have it so you can click the actor that was spawned and it will delete. Then it will have the slot opened back up.

Well you choose what calls the delete event I guess. In your case it sounds like the spawned actor itself calls it. So you’d need your SpawnableActors to have a variable reference to the blueprint/actor that spawned them. Then when you click on any object it calls the delete function on that, and passes itself through.

Personally I would look into using enums and switch cases for this issue

i started off with enums and switches at the very start but it wasnt working well. So i changed to the boolean system. Now im on array setup.

How i had it setup before arrays is, i had a blueprint interface in my eye blueprint that gets spawned. And once its spawned if you click it it will activate an event that will destroy the actor spawned. but that doesnt seem to work for this setup.

How would you go about using enums for this setup, that would be better than using an array?

I dont understand what you mean by this. You want me to make a variable like a bool in my spawnableactors bp cast to a branch to the destroy function to start the event?

No casting needed. I would make a variable in the SpawnableActors blueprint, and make it the same type as the main blueprint (the one doing the spawning/destroying). That way each spawned object can ‘talk’ to the main spawner and call the destroy function when needed. You can set that variable to editable and expose on spawn, and set it in the same way we did with the index variable when spawning Eyes (just get a reference to self and pass that in).

From there, when you click on your Eyes object (or any other object that has SpawnableActor as parent), you can grab that variable and call the destroy function

Ok, Let me post some pictures to make sure i have this all correct. Also what do i use as target for the function to start nothing ive tried has worked.

Spawnableactor BP

Custom Event Variable Type

Destroy Variable Type (My Spawn/Destroy BP is Target_Location)

Eye Actor Bp (Cannot find a target for it) This is one of the objects that will call the function from Target_Location BP.

Ok I think that all looks more or less right. Your target in that last shot should be the Destroy variable you created. The ‘destroy this actor’ pin should just be a reference to self.

Yeah thats what i thought it would be. But when doing that i get this error.
95d215c570f9956d9ce973d7fea38ad7.png

Ah, are you making sure to set that variable when you spawn Eyes? When you make the variable initially it will contain nothing (it will be null), so you’re trying to ‘talk’ to nothing until you set it. Back in your TargetLocation blueprint when you spawn the eyes/whatever you spawn, you should now see a pin to set that Destroy variable (give that a reference to self too, so that you set it to the actor that did the spawning).

Ok yes that worked! But now after they are deleted the slot still stays in use. So if i spawn 7 of these and delete them it still says no free slot.

Ok, what does your on-touch event in Eyes look like now? The one that calls destroy. Are you passing a self-reference through there?

Yeah it has reference to self and the target set to destroy.

And the destroy part is connect to the array elum and everything.

Hm, that should be working. The only thing I can think of is maybe something is going wrong with the Slot Index value. You may need to put a breakpoint on that Set Array Elem or use a Print node in there so you can have a look at what value of Slot Index is being used

Edit: Also what does your spawn event look like now?