0
\$\begingroup\$

I am working on creating an FPS style game for learning purposes. I previously was using self created animations for aiming down the iron sights of a gun. The animation would play when you zoom to iron sights and it would hold it there as long as you have the mouse held down. However, talking to a high rated designer, he told me usually it is done with a second camera that sits perfectly aligned with the guns iron sights. I would imagine you would still have to have an animation that then transitions you into that iron sight camera though. Now my animation works fine but I feel I may run into a problem later down the road if I am approaching it the wrong way from the start.

Can someone verify the right way to do this and explain why it is?

\$\endgroup\$
2
\$\begingroup\$

There is very rarely any one "right" way to solve this kind of problem, only various ways with pros and cons. The onus is on you to evaluate which pros and which cons matter for your specific project and make a choice accordingly.

If your animation-based approach is working for you, you're probably fine.

That said, with the animation approach you're relying on the author of the animation to build it such that the sights end up in the correct spot. It seems likely that human error during an animation tweak could result in the sights being incorrectly aligned. Changes to other game camera properties might cause the animation to fall out of alignment as well.

An approach that, in code, simply finds a camera alignment (possibly using two tagged markers on the gun model) and holds that alignment is perhaps less likely to be subject to this error. Of course, you lose some control over the transition to and from iron sights mode, unless you combine both approaches.

An animation-based approach might also require you to toggle your gun sway off in order to maintain the alignment, whereas the algorithmic alignment approach can always keep the sights in the right spot. Of course, you probably still want to disable or reduce any swaying anyway, since it should be less pronounced when holding the gun in a more stable position.

There's a lot of little pluses and minuses like this you have to take into account when making your decision.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

A good approach may be to keep your animation "close" and then interpolate the camera's position between both modes while the gun is rising or dropping.

This could even give the effect that the shooter is leaning his head to the side and up to the sighting position.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.