How to make melee only enemies effective despite player movement

Jroo

New member
Hi, so I wanted to have some melee only enemies that chase the player with a knife. I used the knife that came with the deathmatch kit. It works for the most part, except for when the player is moving, the enemy never tries to attack.


This means that the player can effectively never get hit by melee enemies, so long as they are moving and don't get stuck on anything. I tried making the enemy speed faster than the player's speed, but strangely that did not solve the problem at all.

A friend of mine suggested that I make the attack range increase to a larger amount ONLY while he is moving. So presumably alter the Max Use Distance value:
1652563524341.png
dynamically when he is moving. Before I go about this though I thought I would ask if this is the right direction, and if it is possible to do this at all through the opsive components. Since this seems like it would be a common problem for melee enemies I thought maybe there already is a solution to this, or some way to dynamically change that value without writing custom code.

Also, smaller note. In that video up above you can see that the enemy chasing you kind of stutters as he does so. Is there any fix for this? I'm not really sure what's causing it.

Thanks for any help
 

Justin

Administrator
Staff member
When the enemy is in that state is the behavior tree in the AttackMovement task? One way to debug this is to place a breakpoint within that task and step through the code to determine why the character isn't attacking. There is a lot to the deathmatch setup so it's likely something small that is causing the problem.
 

Jroo

New member
When the enemy is in that state is the behavior tree in the AttackMovement task? One way to debug this is to place a breakpoint within that task and step through the code to determine why the character isn't attacking. There is a lot to the deathmatch setup so it's likely something small that is causing the problem.
Yes the attackmovement task is lit up the whole time he is chasing me or attacking me. You seem to know that something is broken here with the behavior, but I guess I'm not sure what it is? Like how is a melee-only agent supposed to act in the deathmatch kit? Does the agent try to attack you even though they are not quite close enough? Does the agent not follow behind you relentlessly like that?
 

Justin

Administrator
Staff member
There is a lot going on when the agent tries to attack so it's hard to say without stepping through the code. By placing a breakpoint within the task you should be able to tell what is failing - based on your setup I am unable to say what is going wrong since there is a lot to take into account when attacking. If I were to guess it is probably something related to the distance/layer check but it's really hard to say.
 

Jroo

New member
There is a lot going on when the agent tries to attack so it's hard to say without stepping through the code. By placing a breakpoint within the task you should be able to tell what is failing - based on your setup I am unable to say what is going wrong since there is a lot to take into account when attacking. If I were to guess it is probably something related to the distance/layer check but it's really hard to say.
to be clear, I'm asking about how AI with a knife is supposed to behave, assuming no bugs on my end. I don't think I can debug something if I don't know what the state it's supposed to be in is.

I'm trying to ask how these ai are supposed to behave cause I don't see anything in the code or the behavior trees that looks like it would theoretically solve my problem, and just isn't working right.

For experiment's sake I started a brand new project, imported the Opsive character controller and deathmatch kit, and just made one change to the Agent Aydan prefab: I removed everything in the default inventory except for the knife. This is the result:
As you can see the same problem is happening here. The AI just follows the player but does not swing unless the player stops moving and thus you get this sort of weird scenario where you can just backpedal and always be safe. Not to mention there is a good bit of "stuttering" the AI does as it follows you exactly.

So either the default deathmatch AI in Opsive is broken, or is this is how they are supposed to work. In which case it looks like I'll have to add on my own mechanics to fix this like I was suggesting earlier.
 

Justin

Administrator
Staff member
I will need to look into it more as I haven't tested that scenario. The steps above is how I would start to debug it though.
 

Jroo

New member
yeah I'm a bit stuck. I can't seem to figure out why but the active item ability just seems to get spam used a bunch, rather randomly. Shouldn't it not be able to use the active item (in this case, the knife) so long as it hasn't finished being used? It's getting called much greater than the use rate on the knife
 

Justin

Administrator
Staff member
The use event is called through an animation event by default. It is likely being called a lot because the animation is repeating.
 
Top