0
\$\begingroup\$

I've run into a bit of a brick wall on this topic. I've only been able to achieve either only frame independent recoil, or smooth recoil. But not the other.

I think the main source of the problem is the additive nature of applying recoil the camera offset, but I'm not sure.

If I have a given amount of recoil I want to apply per shot, it would make sense to multiply it by delta time. Then I'd want to subtract that amount from the remaining offset, right?

Well no, that doesn't really work. Since we're adding camera rotation each frame, any configuration where we scale by delta time, we'd be adding an inconsistent amount between framerates.

Now if I use some kind of lerp function with a speed value (For example:

recoil * deltaTime * SpeedValue,

Lerp(0, recoilAmount, 1.0 - Pow(1.0 - InterpSpeed, DeltaTime)),

b+(a-b)*exp(-decay*DeltaTime), 

etc)

Well theres an issue with that as well. The issue is that the speed value usually affects the final offset in some capacity. Again, likely because it is continually adding a value a greater total times on a higher frame rate, rather than directly setting a value between two values.

The only way to "fix" it is to make the speed so fast, the interpolation is nonexistent or imperceptible. But that's not really a fix at all. We're just back to consistent recoil with no interpolation.

Does this mean I have to interp to a fixed rotation offset value, rather than directly adding to the current one? Or will I just run into the same problem?

What are some methods you've seen/come up with that solve this issue?

\$\endgroup\$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.