Monster attack actor detection

Hello everyone,

I have a question about one of my monsters. In my game, I have several monsters. All have a lot of attacks, etc, and are working well. I would like to create another monster, but I have issue with this one for the detection of the hit actors.

Ordinary, on my monster for the detection of players that are hit by an attack I use little box that I place on the arms (3 or 4 boxes per hands, depending of the size of the arms and of the monster), and then I use them to do a multiline trace by channel. Like this, the collision detection is perfect.

On some of them, I have projectile, for example one of my monster is throwing a rock, so the rock is another BP and I add a box collision all over the rock and then do a “begin overlap” node to see if my projectile is hitting something.

My issue with my new monster is that on some attack, when he is far away from the player, he stretches his arm to hit him. To do it on the animation, the creator of that monster move the hand location during the animation. It is really a cool attack but it is causing a lot of trouble for me because I didn’t manage to detect if an actor his hitting between the shoulder and the hands.

Because, if I add boxes on the arm, then the part that is stretched will never detect anything.

My new monster to adapt is this one :

Anim prev :

If you see the animation previsualisation (00:12 ) you will what I mean by stretching his arm.

I think about a lot of things :

  • Creating socket that I place during the animation to dynamically create boxes… but it is not good because the socket don’t move correctly in the animation (don’t stay on the arm), so it will not work.
  • Trying to do a line trace at different time of the animation between the shoulder and the hand, but it means I can’t just do that, I also need to do my other line trace (perpendiculary to the previous one) or I will miss my actor. So it is quite complicate (not impossible but…)
  • Adding a big box collision on the hand and do an overlap detection but the box will not stretches as the body do so it will not work
  • Should I do an overlap detection with the mesh body itself ? But it is not really optimised, isn’t it ?

Have you any other idea to help me finding a solution ?

Thank you a lot for your help and your time ! (and sorry for my bad english…)

All the best,

Unfortunately AFAIK there is not much you can do with this without some logic. Usually the hitboxes are linked with bones and I believe they deform as armature does, but if the animation is just two bones moving away form each other and no bone is actually stretched between them you cannot rely on engine to help you.

You’d have to spawn/activate the physbody created just for this animation during the animation itself so it would register.

1 Like

Hello ! Thank you for taking time to help me :slight_smile:

I am sorry but I am not sure to understand what you are saying when you say :

“You’d have to spawn/activate the physbody created just for this animation during the animation itself so it would register”

When you say activate the physbody, you mean for example activate the detection of overlapping elements on the mesh, like doing a "on component begin overlap on the mesh ?
And then, activate this detection of overlapping element only during the animation by using a notify ?
I am sorry I think I understand badly what you are saying :frowning:

Yeah something along those lines. You can lower the overhead of extra phys body by “turning it off”, so it does not have to detect anything and “turning it on” on anim notify.

Problem is obviously how to position the body right and at the moment I’m really not sure.

I would approach this problem by either getting position of the starting joint and ending joint and place the volume accordingly, which requires some math, or edit the skeletal mesh itself in some 3D sw, adding the bone that would be connected to those two joints, setup constraints in engine so it is attached to them at all times and assign physics body to it.

But these are just hard guesses/concepts that should work. I’m afraid you’ll see what makes more sense as you’ll go along.

Edit: What you mentioned with “On Component Begin Overlap” is the last step, if engine will trigger this event for you that is it, the problem is there is no component to call this on since there is nothing between the joints that would register for any collision detection.

Ok, I understand better what you said, unfortunately I have no idea how to do it, I am not familiar with 3D, I am not a graphist…

But are you sure that this step is necessary ? I mean, I am sure that it would be more optimized to do what you say. But I think it already work if we specify the mesh as a component.
A long time ago, when I was creating my first player and AI it was how I was detecting if an actor take damage or not (Yeah… I was testing if the whole mesh was colliding with the player…) but even if it wasn’t good, it was working.

So, if I didn’t manage to do what you tell me, at least I think I can use the whole mesh to test overlapping, don’t you think ?

Ah sorry I may have mistaken your post with someone else’s who also had problems with collisions. Yes you can obviously make the mesh use complex collision. The problem with this approach is the obvious overhead and I’m not sure you can do this switch at runtime. So there is a chance you have to have it enabled for every instance of this enemy and there is nothing to do on anim notify.

Unfortunately it is relatively complex problem so the 3D approach would be the easiest, but as I said I don’t have exact solution in mind as well. I’d try to search for something like “organic collisions” or maybe even just collision setup in games or something along those lines. But I believe it is not that easy of a task.

TBH maybe the easiest way would be to do sphere trace cast form the position of starting joint to the position of moving joint every frame starting by anim notify and ending on anim notify as well and if you register something there you know something was hit.

Thank you a lot for your answer :slight_smile:
Yeah, in my mind if I do this solution that is quite… stupid but at least working… I will use anim notify only to switch a boolean to true/false to know if I should or not take care of what is overlapping with the mesh. Otherwise, Maybe I can change the collision preset in the anim notify (something like ignore objects response the major part of the time, and then when animation happen, I change to overlap only pawn and ignore the other). But I have no idea if changing the collision preset is heavy or not. Maybe someone could tell me.

Yes, the best way I think was what you said about the 3D approach… I will at least try to learn a bit about how to do it on the internet but I am not sure I will manage to do this way, but I will try :slight_smile:

Thank you again for your answer and your time. I will test this in the few next days, and during this time if someone think about something else it could help :wink:

Ok, so this morning I manage to make it works. Unfortunately, I wasn’t able to do what you said, but at the end it works.

I do the following :

  • I click on my mesh and set the collision response to overlap the pawn. I also set the “Generate overlap event” to FALSE
  • in my AI BP, I add a “on component begin overlap” on my mesh, followed by a branch to test if what is overlapping is a player.
  • I create a “Anim notify state” in my attack montage. I set it for all the time where the arm of the monster is supposed to collide with me.
  • Then, in the ANS blueprint in the “begin” I get my AI BP, get my mesh and set the “generate overlap event” variable to true.
  • In the ANS “End” I set it to false.
    Then it works :slight_smile: