-1
\$\begingroup\$

Let's take typical modern RTS game which features a large map (say 256x256 tiles). There's also a minimap in the GUI, typically up to 256x256 pixels in size. (Let's take these numbers for upcoming example)

We can move viewport with very high accuracy and precision using scrolling (WASD or by screen edges) or dragging (e.g. with middle mouse button), e.g. as precise as 0.001 tile (when zoomed in). However, when viewport is being moved using minimap, this means that for each 1px move of our cursor in GUI we need to move the viewport by exactly 1 tile. The problem is that this feels quite jittery. There's no room for interpolation, since GUI can not go past 1px accuracy.

Which leads to the question: How to smooth viewport movement when using minimap?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

I think you should avoid setting your viewport position to the value selected in GUI in one, single frame.

Instead, I'd add a target position and current speed to your camera. Then, clicking and dragging your minimap would just set a target position of your camera to a new value, but the Camera would use it's speed and target to follow the target pos. during few frames. This way the precision of your clicking on minimap would be still 1 tile but the camera positions can be interpolated between tiles, so you have smooth movement with varying speed.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ To add to this: You would likely want to set and snap to the target position on a user's mouse down, and then only tween your camera to a target position on a mouse drag. You may find however that the goal of moving via a minimap is really all about speed and accuracy; The behaviour you're looking for may be a solution to a problem that doesn't exist, or rather, a solution that is a tradeoff with accuracy of the minimap. \$\endgroup\$ Commented May 26, 2017 at 14:19
  • \$\begingroup\$ @DannyYaroslavski You are right, the smoothing effect should be just enough to kill the jittery of the slow movements. Responsiveness should not suffer. \$\endgroup\$ Commented May 27, 2017 at 7:51

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.