Beat Em Up - Why are two enemies both picking up a knife and throwing it?

So I’m at the point of the Beat Em Up template where I’m starting to work on enemies going after and picking up weapons. So to keep this simple, I will just have them go after one weapon, a knife. They will go to, pickup and attach the knife, and then once they have it, if they are on or fairly close to the player’s X (horizontal) with their capsule component for TWO SECONDS, they will detach and throw the knife at the player, and if it strikes him it is an instakill.

I have assumed there needs to be what I’m calling the “object of interest” for the enemy.

Which will check if there is ANY weapons present in the “screenbox” (which is just a box collision that takes up pretty much all visible area of camera), and if so, the goal then becomes to go to and get said weapons.

Again, this will only be using one weapon for now, but I assume it will work like this in the end. So I first check if the enemy has any weapon, and if false proceed. Then I check if the knife actor is overlapping with the screen box, thus a weapon is present or not. If so I’m setting my X Y Z floats with the knife actors location.

Which ultimately feeds the main enemy movement mechanism.

Now here comes another Beat Em Up serious question…How do you decide which enemy goes for the weapon? And which weapon? And once ONE enemy goes for the weapon, the others do not? hahaha

Now we come to the question of this thread…in the video you see both of the first two enemies go for the knife, and when they get there, they both reach down for the knife, it obviously attaches to the first one that got it. Then after the two seconds on X, they BOTH throw a knife. You might not be able to tell they are both throwing a knife in the video but they are. But I don’t get that, the two enemies don’t act like instanced copies.

Here is what I done, I have just one Enemy001 BP (which is already very complex and it is not even done yet) which was dragged into the world and placed and rotated, and from that all the others are clones of that one.

Yet, in this case they don’t act unique. And there are other cases where they act too much like one. Walking so closely to each other they sometimes merge into one enemy and it look like there is just one but there is actually two there. Which means when the TPC gets punched every one of there punches is actually two.

I figure it may be that I didnt actually use seperate blueprints for the enemy, and while I did do that with the miniboss, I did not want to do that with the enemies as I wanted to have one enemy bp really good before I cloned it and made others with some slight changes.

Check if TPC Capsule X in range compared to Enemy’s capsule.


And before I forget, you probably want to see how I attach the weapon.


As always, any insight or wisdom about what is going on here is greatly appreciated thanks!

It’s probably detecting the knife that is in the hand of the character for the clone. You probably should add a parameter to the weapon isEquiped and set it to true once a character picks it up, then on overlap check against this parameter.

Also if you are using a blackboard for ai then check if the parameters are shared or set to per instance.

1 Like

I sort of see what you are suggesting, I tried putting a branch just before the attach happens with the has any weapon boolean that immediately is set to true after the attach hoping this would stop the second npc pick up. But it did not, there may be more to this, as even if the NPC that doesn’t get the knife is destracted a bit, he still walks over to a spot and bends over and picks up a phantom knife, and though you don’t see it attached, he is able to throw a knife somehow.

Not using the blackboard.

Ok, so how I finally stopped it was like this, I added an “Available” boolean inside the knife actor and set its default value to true. This would be like a weapon is on the ground so it is available.

Added and AND bool to the object of interest macro to also check if it is available besides just overlapping the screenbox.

And set the variable right after the attach in the get weapon macro.

Something else to add, I’m still seeing enemies merge together and walk as one, may try to see if the enemy’s capsule will block another enemy capsule.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.