Is it possible to set a variable on a single spawned bp independant of other spawned bps?

I have several instances of the same bp spawning in my level. When one of these bps crosses a certain area of the game play screen, a variable is set (i.e. the bp actor in that area will start moving around). I noticed, however, that once one instance of the bp enters this area, the variable turns on for all instances of this bp. Is there a way to make it so just the instance that is crossing into the said area will react independantly of the rest?

How are you activating that movement? Can you show your blueprints for this? It is definitely possible to do this, but it sounds like you’re way of firing off that event is affecting all others?


I had to piece this together to make it fit in one image. The first image fires in the level bp. It checks if the enemy is overlapping the trigger volume, and sends that info to the game instance. The second image is from the enemy bp. It is checking that both a weapon has been placed, and the trigger has been stepped on. Then sets the attacking animation to start playing. This works, but as I said aboe, it not all only calls the animation on the enemy that met both requirements, but also every other instance of the enemy on screen.

The issue is that your enemy blueprints are looking at a variable in your GI, which is going to be the same for all of them so they all react. You need to have the bool that determines if they play that animation in the enemy BP itself. Then, when they cross the trigger, you can check it’s the right class as you do now, and cast to the ‘Other Actor’ and update that bool in only the one overlapping.

To make this easier to re-use later in other levels or other parts of the level, you might want to make your trigger volume a blueprint. Then, you can do a generic check to see if it’s overlapping with something you want to interact with and do different things depending on what object it is. The less you have in the level blueprint the better from my (admittedly limited) experience.

I’m not sure I follow. The variables it is looking at in the game instance are the ones that mark the location of the weapon and the trigger being overlapped in the level. However, the actual variable that tells the enemy to attack is stored within the enemy’s bp itself.

Maybe I’m missing something, but from these screenshots that’s not what I see. In your BP_BasicAlien example, you are getting 3IOverlapped from the GI_Aliens blueprint. If that is true (along with 3IFilled), then the animation plays, right?

The issue is that 3IOverlapped is getting set in the GameInstance which is being looked at by all of your alien blueprints so they all react to that change, not just the one that hit the trigger. It’s the difference between sharing a beta code on the big screen in a giant stadium or sending it directly to one persons’ email. If it’s on the big screen, everyone in the stadium knows about it and can use it. If it’s in the email, only the one targeted with that email can use it. Does that make sense?

I would suggest making a separate blueprint that is just a box component with overlap collision. In your alien blueprint, set up a check similar to the one in your level blueprint to check for overlap. Ensure that the OtherActor that is overlapping is the blueprint with the box component and then have it set the overlapped bool in your alien blueprint. This way, only the trigger blueprint and the alien that are overlapping are involved. It also allows you to place those triggers all over your map and not have to update each one in the level BP.

Ah, okay, I misunderstood which bool you were talking about above. I will give this a try. Thanks.

I set up a quick trial to help explain it better. I have a trigger blueprint here:

Trigger_BP.png&stc=1

This is just a cube component stretched to a flat rectangle, but could be anything you want and if you look around you can find ways to manipulate the size and shape for each one you place so they can fit wherever you need them in a level.

I then made a quick cube BP to replicate your aliens. Just another cube component with a text render component on it that changes if it’s in the trigger.

&stc=1

The key here is that the ChangeText bool is in the Alien BP so that only the Alien crossing the trigger is getting that changed. You don’t need to do it on tick, you could create a Function or CustomEvent and just call that from the trigger, but the main thing is to get the variable into the BP being affected.

Here’s a video of it in action to show the value of doing it this way. Sorry about the audio. :slight_smile:

https://youtu.be/s06nEXSr6jk

Hope this helped.

Thanks for this. I tried setting up an overlap bp like you did. And while it is reading it as overlapped, when I compare the overlapped variable to where a weapon is placed (ie. 3IFilled), it doesn’t read it as being filled when it is. In other words, it doesn’t execute the change in animation at all.

The “3IFilled” bool is checking if a weapon is within that grid space. The “overlapped” is set from the overlap box bp like you set up above. This funcion is inside my Alien bp. I did a print string to check if the overlap was working, and it is. I also checked to see if the weapon is ticking as filled, and it is working as well. What am I missing here?

Not sure how you’re setting that 3IFilled bool so it could be just about anything. One thing I’ve seen (and honestly don’t remember what the fix would be) is that if an object starts inside of a trigger, it’s not recognized as being there. However, you say you can see it being set to True so I’m not sure what else is going on.

Don’t thing this will matter, but you don’t need the Bool == nodes before the And node. When a bool is plugged in to an And node (and most other bools) it’s looking for True automatically so you can just plug them straight in. Again, not sure that would be messing with your situation or not.

Can you give more info on how the 3IFilled bool is being set. Might help in figuring out what’s going on here. In the meantime, what if you just check for Overlapped? Does it work the way you want it to then?

No, it doesn’t because it is only supposed to change to the eating animation if the trigger box is overlapped AND there is a weapon set on it. I figured out the one issue of it not firing. I had the “Eating” function after the branch rather than before. But, once I changed it to the correct position, it went back to doing what it had been before, which was setting all instances to change to that animation, rather than just the one that is meeting those requirements at the time.

To explain this a little easier, my “grid” and game plays simillar to Plants Vs. Zombies. There is a grid of five rows with nine grid spaces in each row. Each grid space has a target point on it to determine where a weapon can be placed. These grid spaces are a 100 x 100 square with a trigger and light (that lights up when hovered over). If the user clicks on a space, the location of its corresponding target point is stored into a variable (spawn transform), and the “clicked” bool for that particullar space is set to true in the game instance. The blueprint for this looks like this:

Then, a couple things happen in the game instance. First, I compare the spawn transform variable’s location to whether or not that space has already been filled. If it has not, then a bool is ticked to true, stating that space is available to place a weapon. That function (in the game instance) looks like this:

Second, I check something similar to the last step, but this time I compare the spawn transform variable to which grid space had been clicked. If it is true, it sets the variable for “filled.” That looks like this:

The info from the last two steps is then called in the umg event graph that contains the weapon selections. This graph checks first if the grid space is free (using the the first step in the game instance), spawns the weapon, and then runs the second function in the game instance to mark it as filled. That graph is this:

Just a note on the two functions in the game instance…I had tried this several different ways, but all other ways I had tried had made it so that multiple weapons were able to spawn on the same grid space, when there is only supposed to be one allowed per space. So, I implemented these two functions which fixed that issue.

Also, the “eating” animation is basically the alien attacking the placed weapon. The weapon takes damage over time, and if the alien destroys the weapon, the “filled” variable is then reset.

I moved all overlap, click, and fill events to the alien bp. And, when it is spawned in the level bp, I also drug off the pin to promote the alien bp to a variable. So now, when the grid space is clicked, it should be sending the bool as ticked info to the alien bp. Problem is, it is not working at all now. When I close the test play window, I get an error message, stating “Error Accessed None ‘BP_BasicAlien’ from node Set 3AIsClicked? in graph ‘EventGraph’ in blueprint LevelOne”