Hey all
I’m using UE4 - 4.4.1 and decided I would try adding a socket to the Mixamo Maria character and seeing if I could get some sword swing action going.
I followed MetalGames tutorial which is simple enough. I am using the sword mesh from the CouchKnights content as my Static mesh to attach to the character
Set up exactly as it is in the tutorial, except when I start my game my camera is offset (inside the character body) until I walk around (sometimes it will give a 3rd person camera)
and sometimes when I swing the sword, it will look fine but the character starts moving on it’s own and jumping off the sample level…
Anyone have any ideas about this glitch? I’ve prepared a video for your viewing enjoyment…
Thanks all
Have you changed the location of the spring arm component at all? And if the sword has collision, how does the collision box look in static mesh editor?
That’s a collision problem -> I would do the collision with a box which should be placed a little bit away from the sword/hand (otherwise it will collide with the player -> you get the result in the upper video)
Or, instead of what said, you could make the sword ignore collision with the player character.
Honestly swords probably don’t want collision, there are almost no circumstances where that would be the case. Melee attacks are typically animated as swing-throughs, you’d want the sword’s collision data to only fire off overlap events. You would just have relevant actors (i.e. The player) ignore overlaps from the sword while having the enemy pawns recognize them.
You know, i was looking at the swords collision box and thought “man, thats a big collision box… Wonder if that has something to do with it…”
All makes sense enough to me.
I’m currently at work but when I get home I’ll try all your suggestions.
1)What would be the best option if i wanted the sword to inflict damage to an enemy pawn?
2)The collision box on the sword would also be needed if i didn’t want the static mesh going through walls, correct?
1- There are several ways to do melee weapons. You can use overlap events for the sword if you just want to inflict damage regardless of where you hit, or you can use line trace if you want to get the specific bone of an enemy you hit.
2- Having a collision box is just fine(you actually need a collision box to generate overlap events if you need) but you would want to set the box’s collision preset at overlap instead of block in order to prevent this kind of issues.
Along with what said, my take (since I’m implementing melee in my game).
I actually check for overlaps with the sword first, using a branch and a “has tag” approach (i.e. I tag the sword’s capsule as a Hurtbox, and tell enemies to filter collision except from hurtbox-tagged components).
THEN I perform a sphere trace (not a line trace, as in my experience it’s far too easy for melee attacks to fail to register if the animation’s frames don’t line up right, the traces will sometimes just miss the target entirely, especially if the swing is a big angular arc and you hit the enemy on the bottom half near the legs) for a specified duration to determine the bone hit. I do it this way because it seems to me that firing off traces constantly is both unnecessary and probably a pretty heavy performance hit.
Also of note is that the sword should definitely have collision data for interacting with WorldStatic and WorldDynamic objects IF AND ONLY IF it can be dropped in the world and needs to simulate physics there. Otherwise it’s unnecesarily complicated; if the sword is attached to the actor, the sword will resist pushing through walls, but the actor’s skeletal mesh will be animation-driven, and this can lead to unpredictable results. Honestly it’d be better to just let the sword clip through environmental geometry when wielded by a player, in my humble opinion. I think most players will be willing to suspend their disbelief if the alternative is unpredictable movement behavior near walls on account of the sword.
Ok I’m finally home and able to look at this again…
I’m not sure where exactly I’m supposed to change the collision properties though =/
I found a checkbox in “Details” under the static mesh for the sword… but unchecking gives me the same results.
I have also used the same pillar from the tutorial, causing the same effects as the sword mesh… So does that mean there’s something up with the collision on the character instead of the static meshes I’m trying to use as a “weapon”?
EDIT*
I also did a “Simulation” on my Level BP and got these errors…
*Info Play in editor start time for /Game/Maps/UEDPIE_0_Example_Map 0.935
*Error Accessed None ‘CallFunc_GetPlayerCharacter_ReturnValue’ from node Attach Actor to Component in blueprint Example_Map
Would this have something to do with it?
I also changed the option on the “Attach Actor to Component” in the Level BP to “Keep world position” and all the glitches in the above video are gone.
Save for the fact the sword is floating and swinging 20 feet away from my character
*EDIT 2
After playing around even more, I set the collision to “Use Complex as Simple” THEN unchecked the box and now I can see the animation, and no more crazy jumping around the screen…
But what ill effects does turning the collision off like this pose for me?
Using complex collision as simple uses a vertex-for-vertex recreation of the asset as the collision data. The disadvantage to so doing is that it’s an increased performance hit (it effectively has to draw the sword twice) though unless it has a stupid-high vertex count it’s probably not a big deal; more of an issue for geometry that’s iterated a lot across a level (e.g. using complex collision as simple for assets like walls and doors can chew up GPU power pretty quick since that’s effectively doubling your whole level geometry).
The real disadvantage, imo, is you didn’t learn how to solve the problem! By doing what you did you essentially changed the size of the collision geometry in a way that relegated your weird bugs with collision to edge cases because the sword is much less likely to strike the player capsule. But they’ll still arise; it’s better to read the docs on collision channels and learn to set object/component collision settings since you’ll have to do so eventually anyway.
@RhythmScript
Indeed, you are correct. I’m not calling this problem solved yet I still want to find the root cause of those glitches!
That was the only thing I found that would cause them to stop… So far.
I’m working evenings, so i get home late & don’t get much time… So tonight’s another attempt, lest i pass out on the keyboard again lol
Any suggestions where i should be looking to find the root cause?
Thanks
Hey all.
Finally able to get back at this problem… it’s been like 2 weeks.
I’ve been changing things all over the place and still can not come up with a solution.
I have noticed however, that in the VR game’s Character Blueprint the character has the sword equipped but when you open the skeletal mesh it does not!
So I am trying to reverse engineer how they are able to equip the sword mesh without adding it directly to the Character skeleton/weapon node.
Still looking for any ideas on what is causing this, and where it’s located.
That’s because the sword is a separate mesh(and it would be a separate BP if you want to make it an actual weapon) and that’s how you should do it. If you look at the character BP of that VR project you’ll see the sword as a static mesh component, not a part of the character skeletal mesh.
If anyone still has this problem the solution is to go to your character blueprint, click on your SpringArm or Camera Boom and in Details under Camera Collision untick “Do Collision Test”.