Hi, I have a Character and at a certain point in-game its Root CapsuleComponent’s collision is disabled and the SkeletalMeshComponent, the mesh, is set to Simulate Physics. The Mesh has blocking collision settings, Generate Hit Events checked and also Use CCD and Always Create Physics State.
The Hit Event and the OnComponentHit Event aren’t fired once the Root has its collision disabled. The character, though, doesn’t fall and can impact other world actors.
I’ve also tried, instead of disabling Root capsulse’s collision, setting it to ignore WorldStatic and Pawn channels, and the mesh still doesn’t fire Hit.
This is in BP. I’ve tried both with Hit Event and SkeletalMeshComponent’s OnComponentHit. I’ve made sure they are not working in the exposed situation because they would perform Print String and have been marked with blueprint breakpoints with no notification while in-game.
Hit Event and OnComponentHit both work perfectly (are fired) with a channel if the RootComponent of the character blueprint, the CapsuleComponent, has a Block response to that channel, and that with all channels that meet the condition.
That makes me conclude that currently it seems that in UE4 the collision response of the ROOT in the character needs to be Block if one wants any other component in the character to be able to deal with Hit so collision with that channel is processed.
If this has currently a solution in UE4 I would be very thankful to read about it. Otherwise, take this comment as a request for solving this , I’ve made some request threads on the matter in past weeks but with no replies yet.
I’ve been messing around with a few variations of his setup and am having the same results. I used the ragdoll C++ code I had and converted it to BP for the mesh. I disabled the capsule component and then enabled the ragdoll stuffs on the mesh to get it to fall to the ground. See BP image below. No HitEvent for the SkeletalMeshComponent called Mesh.
I did do a test with a CapsuleComponent and a SphereMesh that was a StaticMeshComponent that did what he wants. It read the HitEvent for the capsule, I disabled the capsule and enabled the SphereMesh, then the sphere static mesh fell and it registered the HitEvent.
It makes me wonder if the SkeletalMeshComponent for the player model doesn’t have the same collision registration as the StaticMeshComponent. My static mesh sphere had a Collision Primitive on it from the mesh editor.
This is an interesting problem. I’m also interested to know what you are trying to achieve. We might be able to suggest an alternate implementation that would work for you.
Hi, AnXgotta, thanks for your time for responding.
I think that StaticMeshComponent Hit wouldn’t be processed in a Character blueprint subclass, even if it does in a normal blueprint. In Character, I’ve seen that non-Root components (SkeletalMeshes, capsules, spheres…) don’t fire Hit for a certain channel if the Root has Ignore response for that channel.
Also, if Root collision is blocking, apparently Hit for other components will be only processed if the Root capsule is also blocking against what is blocking the other component.
As you may agree, this is a limitation for a fighting game like the one I’m working on, so I can’t detect Hits when the SkeletalMeshComponent’s fist punches into another actor, just because the capsule isn’t so big to cover the whole scene, but just the body of the character. Trying to make the Root capsule very big first leads to Monkey Ball-like weird effects, but then you have to disable Root’s collision for some channels, but as said then you can’t detect component’s.
Currently I have a tracing solution implemented, which works pretty well, but I insist that it would be much better if in UE4 it was possible for Character components that are not Root to deal independently with Hit events. So if someone knows how to solve it I would like to know, if there’s no way, take this as a request to implement what I believe would be a very important feature.
What if those components are not really attached to the player but exist in space and move similarly to the character component?
Lets say your fighting character does not have collision, but the 5-6 collision volumes attached to/above/etc his arms, legs, torso, and head do take collision?
I don’t know how well you could make the volumes follow the movement of the character model(or how detailed your game must be in this aspect), but it could be worth a shot.
Hi Zeustiak, thank you, that’s in fact a good idea, I tried out something similar with overlapping some time ago, but possibly because of an early bug with Begin Overlap that now is corrected it gave bad results.
With Hit it could be a good solution. The only problem I can think of is that the body capsules could bump with the Root capsule (that even if the mesh was not blocking the Root would need blocking collision to avoid falling and for some character-based functionality). This might be possible to solve using Tags.
Ok, so I’ve tried using an auxiliary actor with a capsule component that is attached to the mesh’s fist for punching detections. I’ve tried Overlap and Hit.
Hit gave probelms because just when spawning the blocking actor it made the character uncontrollable and buggy (it moved wildly against controls). The solution I wanted to use for this predictive case was use Tags in the auxiliary actor’s Hit event so if it collided with its owner character it didn’t block it. But I can’t use this because Hit isn’t being called for collisions with the character. It seems weird, but might be because it’s at hand socket location, beyond the scope of the capsule, so again the collision detection being Root-capsule dependent is causing problems!
Overlap: I’ve tried, as an alternative, setting up “Get Overlapping Actors” with some Branches to see if the auxiliary-hand-collision-actor is overlapping another character and not self. As puzzling as it can seem, the attacking action is only processed if at start of the punching animation the attacker’s auxiliary collision actor is touching the Root capsule of the other. So that’s the problem with Root again!
I’m using Continuous Collision Detection and Physics Sub-stepping, so it can’t be a precision thing.
So I thought it could be a problem with Attach, so instead of attaching the auxiliary actor to the character’s mesh hand socket I’ve tried a crappy thing consisting in Set World Position of the actor to the socket location some times each second; the problem persists.
So my request for Root-independent collision for all components in a character BP subclass is still there.
Your collision channel presets on all the actors are set properly right? Your custom channel for your collision volumes should be set to Ignore for the player channel, and the player should be set to ignore for the volume channel(s).
Then you have channels for the enemy’s character and volumes so that your volumes can interact with their volumes. Could get complicated depending on how many characters are fighting, but you should need at most 4 channels to cover 2 characters I think.
Thanks again, Zeustiak. I think this should work with one single channel for all players’ characters, not 4 or more as you suggest, a channel for colliding only with other auxiliary collision actors, but that doesn’t collide with, but ignore, any other thing in the world.
I’ve set up a new channel and assigned it to the auxiliary collision actor, and I’m spawning it at Begin Play and attaching it to character’s SkeletalMeshComponent socket in the hand. It gets nicely attached in-game.
The auxiliary collider actor has “Object Type” set to the new type created, called “Collider”. It has “Collision Enabled”. It has “Ignore” responses for everything except of “Collider”, which is “Block”. It has “Simulation Generate Hit Events”.
However, “Event Hit” just never fires in the auxiliary collider actor. Never. I’ve also tried it with “Simulate Physics” on, but nothing. I’m checking if it gets fired both with “Print String” and Blueprint Breakpoints, but it’s never fired.
I must be missing something.
What could be preventing the axiliary collider actor to fire Hit events?
Have you tried all the simple collision options and the “Complex collision as Simple” option?
One more thing, if you haven’t tried already, would be to attempt some trace hits or sphere overlaps on your actor. See if it works with that method then you have a better idea that it works, just not in the situation you want it to.
If you can get a line trace on it but it won’t collide with the other objects, maybe you could play with the size of the volume? Expand the collision volume out a bit and see if you can get it beyond the influence of the capsule.
If that works then you may have at least confirmed it is a player capsule problem.
I’ve found a nice solution for my situation, in which I had to detect accurately when a character punches another one, might not be the best for others’ contexts, but here it’s just what I needed.
Now when the punching event is fired, I activated a man-made sort of foreach loop ( Delays in actual flow control loops included with UE4 don’t work ) in which a “Single Capsule Trace for Objects” is executed for each frame (I’m using Delay with “Get World Delta Seconds”, which is the time in seconds corresponding to a frame duration, the reason to use this variable value and not a constant float is for performance: if FPS are really high the accuracy is maximum, as tracing is processed each very few miliseconds, but even under 10FPS it gives nice results without affecting performance).
The capsules of the trace are set to be in the location of the hand socket, I’m using “Get Socket Location”, outputting from Mesh variable in the character, works for Bones as well.
If the capsule trace detects a character, the consequent actions are processed, and through the use of a bool the sort of loop mentioned above is stopped. After 0.5 seconds the loop is set to be stopped anyhow.
Just to add to this… the frame rate issue in this trace style can be a big one. Especially in online play.
A way to fix this is to do a line trace from the socket position from one frame to the next and trace for player hits. Simply cache the socket location for this frame, then in the next frame iteration get the new position and trace from one to the other looking for character hits.
I made melee functionality in a different game and the frame dependent tracing isn’t good enough, you need that extra trace between frame positions.
Hi, AnXgotta, I can see the point of what you say, even traces in 10 to 60 FPS aren’t in ingame influence very different, I might implement something like that for an extra level of accuracy, so thank you, in very fast movements I could add in the future it would possibly be specially worth.