Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to handle collision for fast melee animation at lower FPS?

Hello everyone,

I'm struggling to resolve this issue. In my game, melee combat makes up a large chunk of the gameplay, so it must be as frame independent as possible. Unfortunately, when I test out the collision at lower FPS (20 fps), the melee swings are missed completely. Currently the collision consists of simply a collision box with CCD enabled attached to a mesh, and that mesh is attached to the player's hand. At higher FPS it works perfectly, but once you dip below 30 it starts to miss very clear hits.

Here's what I have attempted:

  • Enable physics substepping: I enabled this setting and played with the values and saw absolutely no difference in the accuracy of the collision. At 20FPS the swings still missed.

  • CCD: Also no difference.

  • My own custom collision: I coded my own simple collision system in C++ similar to the way Chivalry handled theirs; line traces drawn between the previous frame and the current frame along two sockets. Unfortunately at lower FPS the shape still gets distorted enough that a lot of weapon range is lost.

Are my animations just too fast that I can't use them reliably? Is there anything I can do to achieve reliable collision at lower FPS? 20FPS I'd consider a realistic dip, but even at 25FPS collision still misses.

Wasn't Street Fighter V made in UE4? How did they handle their collision, it can't be framerate dependent can it?

Thank you for any help.

Product Version: UE 4.18
more ▼

asked Dec 09 '17 at 12:26 AM in Using UE4

avatar image

1 2 4

avatar image Jin_VE Dec 09 '17 at 12:36 AM

Are you testing that the box collides with a mesh or some other collider (on the receiving end of the melee attack)?

avatar image fernmerc Dec 09 '17 at 01:10 AM

Currently I'm just testing against Pawn, so in the case right now that would be the CapsuleComponent that is the default root of Characters. I might want to move it to mesh in the future though, does that have any effect on the accuracy on the collision?

Thanks for the reply!

avatar image Jin_VE Dec 09 '17 at 01:17 AM

That should be fine. And is the capsule also set to CCD?

avatar image fernmerc Dec 09 '17 at 01:27 AM

It wasn't, but I turned it on just now and the issue still persists. I thought about going with something along the lines of a pre-calculated sweep, such as spawning a large collider during the apex of the swing, but then if I hit multiple targets they will all get sent back at the same time and it won't feel organic.

avatar image Jin_VE Dec 09 '17 at 01:35 AM

CCD should be doing that already. That's how it works. Are you using block or overlap? Pretty sure CCD only works with block. Next time I reply I'll move this to a (potential) answer.

avatar image fernmerc Dec 09 '17 at 01:46 AM

I was using overlap... I switched it to block but now I can barely walk since the sword itself is pushing the character haha. I managed to get close enough to the enemy to test it out and it's more or less the same, but hard to tell since it actually pushes now... How do you recommend I test this?

Thank you so much for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

So what you want to do is use the block as well as the 'hit' events ("On Overlap" won't work anymore). Then you need to make sure the colliders don't collide with their owning actors. Most of that functionality involves the label "ignore", like "Ignore Actors" or "Ignore Self".

You may also need to set up collision channels so the weapons only hit what they need. But since your combatants are the same class (I assume) that won't be enough. If they happen to be different kinds of actors then it's pretty straight forward to set up two collsion channels so the weapons of one actor only hit the other type of actor (and vice versa) -- as well as any obstacles, which should be blocked as well.

I learned about this type of functionality by watching a tutorial from Epic. I'm pretty sure it covers what you need.. It can be found here https://www.youtube.com/watch?v=hRO82u1phyw.

Let me know if that isn't sufficient.

more ▼

answered Dec 09 '17 at 02:01 AM

avatar image

4.4k 32 79 42

avatar image fernmerc Dec 09 '17 at 02:40 AM

Thanks for the answer! I'm almost there, but I can't figure out how to get past one thing. My hits are not being detected unless at least one of the two actors has "simulate physics" enabled. If I enable simulate physics, then if there is a collision the one simulating physics goes flying. Is there a way to get hit events without simulate physics on?

avatar image Jin_VE Dec 09 '17 at 03:00 AM

Oh, I misremembered. You want to set "Collision Enabled" in "Collision Presets" to "Query Only" (No Physics Collision)". Then you should get the hits.

avatar image fernmerc Dec 09 '17 at 03:05 AM

I just tried it on both, but no hit events fire now. If I set collision enabled on both of them and enable simulate physics on one of them, then it works, but I can't use that since then gravity is applied and the issue described above. Have you managed to get it working like this?

avatar image Jin_VE Dec 09 '17 at 03:18 AM

I looked at a working project. My bullets and mesh are set to Query only and the bullet hits the mesh, firing the hit event. It might be that the collision channels are not set to block the right object types. Though disabling physics shouldn't change that.

avatar image fernmerc Dec 09 '17 at 03:34 AM

I'm glad to hear it's working for you, that means I'm just doing something wrong. Would you mind helping me out? Here are the exact same collision settings I'm using for both the sword, and the mesh I'm trying to hit:

alt text

Like you said, it's probably not something directly in the collision settings since as soon as I set either of them to simulate physics (and both to collision enabled instead of query) it works.

a1.png (26.4 kB)
avatar image Jin_VE Dec 09 '17 at 03:38 AM

If you're using the capsule then set the Pawn to Block. And make sure the capsule's object type is pawn (the default, or set it to whatever object type you changed it to). You also want the capsule to have Block set for the Weapon object type.

avatar image fernmerc Dec 09 '17 at 03:43 AM

Ah no, right now I'm literally just placing a collision box with those settings, which are the same settings that the sword has. Since they're both of type weapon then they should call "hit" when they overlap no?

avatar image Jin_VE Dec 09 '17 at 03:48 AM

The weapons will collide based on those settings. In addition, you need the weapons to hit the capsules (you said you were using capsule at the moment). The capsules (by default) are set to Pawn as the object type, so you also need to tell UE4 to catch the collisions between the Weapon and the Pawn object types. You do that by setting the Pawn to block Weapon and the Weapon to block Pawn. And make sure "Simulate generates hit events" is set on both components.

avatar image fernmerc Dec 09 '17 at 03:54 AM

Yes, I was testing using the capsule, but to speed up testing I just placed a collision box with the settings above and tried hitting it with the sword. It should still work right? The settings above are the ones that both the sword AND the box I'm trying to hit have. Since they are both the same type and both are blocking each other, it should still work, but it doesn't.

Thanks again!

avatar image fernmerc Dec 09 '17 at 04:28 AM

I'll mark yours as the answer and I'll make a new thread for this since it's unrelated to my specific issue. Thanks for the help.

avatar image Jin_VE Dec 09 '17 at 05:42 AM

I thought the sword was being represented by the box. You have a collision object on that too, right? Mesh collisions are very costly. Either way, the object type of one actor needs to be marked as blocked in the other and vice versa. GL!

Sorry, please re-mark the answer. I hate that you can't reply without undoing that...

avatar image ViceVersa Dec 24 '17 at 02:14 AM

I think that a possibly more reliable way around this (and i think that you will need to do this if your game includes online multiplayer) is to do a line trace instead of using a collider.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question