0
\$\begingroup\$

There is a video here that shows how the camera rotates around Leon. The camera rotates around Leon in a circle, this is not difficult, but I don't understand the timing logic.

Once given a short push, the camera keeps rotating for a few more milliseconds.

If the camera would only be rotated during the real mouse movement, the camera would not keep rotating a bit after there is no more mouse movement.

However, in this video, the camera rotates a few more milliseconds even after the last mouse movement.

How could this be accomplished?

Specifically, I would like to ask if somebody can tell me if the developers add some extra movement in the direction of the mouse movement which they then "smooth out", or if they "smooth out" the end of the user's mouse movement.

Thank you!

\$\endgroup\$
3
\$\begingroup\$

Implementing this sort of momentum in camera motion (or really just about anything) can be done with easing functions.

When the actual input to the camera movement system stops, you have (or can compute, depending on your implementation) the speed at which the camera was rotating during the input period. Rather than simply set that speed to zero, jerking the camera to a halt, you apply some sort of easing function to slowly reduce that speed to zero, resulting in the gradual settling you see in the video.

This can be done fairly straightforwardly by adding a new state to your camera. Previously you had two states, explicitly or implicitly: moving and stopped. Add a third state, "settling." You can do this as simply as adding a "settling time left" field to your camera that is zero normally, but which you set to a non-zero value representing the number of seconds the camera takes to smoothly come to stop. Implicitly when this value is non-zero the camera is in the "settling" state.

Then, every update, if the camera is settling, keep it moving based on whatever easing function you've chosen and the time remaining, deduct from the remaining time, and there you are.

\$\endgroup\$
  • \$\begingroup\$ Thank you. In RE4, the camera will never face Leons face directly, the camera rotation angle is limited. Do you think they "add" the settling, or do you think they make the last bit of the mouse movement to be settling? I hope you understand what I mean. \$\endgroup\$ – tmighty Feb 10 at 16:46
  • 1
    \$\begingroup\$ Adding the settling is easier; you may be able to tell by watching closely to see if the camera settles after your mouse stops (so it sort of lags behind) or if it settles instead once your mouse gets to a certain low speed threshold. \$\endgroup\$ – Josh Feb 10 at 16:48
  • \$\begingroup\$ You have really broadened my mind with your great explanation. Thank you! \$\endgroup\$ – tmighty Feb 10 at 16:50
  • \$\begingroup\$ Can you tell which easing function they used in the video? \$\endgroup\$ – tmighty Feb 10 at 21:34
  • \$\begingroup\$ I have uploaded another video here: youtu.be/SfDJ9xvB7zw I just don't understand how they implemented this. I've tried really much, taking into account the overall speed until the next zero mouse movement, fading out the last non-zero mouse movement, just anything that I could think of. It never looks like theirs. Do you think you could shed some light on what you think they do / how they do it? \$\endgroup\$ – tmighty Feb 11 at 1:19

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.