Melee weapon collision inconsistent at low framerates

Hi, I’ve been working on a serious project as part of a team for several months now. I’ve been aware of this problem for a while, but the solution I came up with seemed time consuming and I wanted to wait to see if something better developed in the meantime. But with the project moving into alpha testing, I’m forced to give it another look.

Background:

  • I have kinematic rigidbodies with
    cube trigger colliders attached to my
    weapon objects.

  • The weapons are children of the
    player character’s hand bone
    transform.

  • All of the (many) attacking
    animations are tied to the
    character rig and the weapon is
    just along for the ride.

  • I am happy with how it performs at
    60 FPS.

The problem is that the weapon rarely travels in a straight line, so the interpolation between two points and rotations between frames is not accurate to the animation. It results in an attack whose area of effect is slightly different for every framerate. At lower framerates (sub 30), the faster attacks may not collide at all.

This is a PC game, so framerate scaling is a necessity. I can’t just bring up the physics timing to 60 updates per second and call it good.

The (complex and probably terrible) solution I am considering implementing involves baking the important animation frames of each animation into the weapon object itself and giving it a script to correct itself if it becomes misaligned. The reason I don’t want to do this yet is because it will require tweaking every time the animations are changed, which will be quite often in the coming months. Another option would be to create a trail of weapon colliders at particular frames based on the animation timing. They could update a little late and still be sufficiently accurate.

But I’m very much hoping I’ve overlooked something obvious. Thanks for any direction you can provide.

Read this

Its to do with the way FixedUpdate gets cut short to keep framerate consistent.