Set speed of draggable object or Camera

Would be great if we could set the speed of draggable objects to set how fast it follow the position of the mouse when it dragged. At the moment it is instant but in some cases we may want it to be a bit slower, to make the object left behind when it dragged and just slowly move toward the position where it dragged to.

For example, what I’m trying to do now is to drag the camera and move it around similar to a strategy game for example.
What I’m attempting to do is, I center the camera on a draggable object (which is the size of the screen) and when I drag the object I simply want to move the camera along with it. It works exactly as I want, except it way too fast, too accurate. I want the movement of the camera to be less accurate, a bit slower and more smooth. Just imagine a strategy game where you can just drag the camera to see the map. I want something like that by using the draggable object, but the object is too sensitive, too accurate and it make the camera move way too fast to be optimal.

Of course probably I can work around by controlling the position of the camera to not follow the position of the object instantly but slowly move toward the object in case it moved, but it would require work around too as at the moment there is no option to move the camera toward a position but only set it position.

So, I would love to see the option to set the speed of the draggable object.
Or, alternatively an event to make the camera move toward a position at certain speed would be great.


Sorry if it’s a bit difficult to read, but this should resolve your problem (regardless of the suggestion, which is fine). The workaround should work well, but my code is not optimized (some “execute once only” and etc. could be added), just for example.

P.S. The actions on mouse click released also resolve the potential issue of draggable object getting out of screen (since camera is purposely lagging behind, to make smooth movement).

This kind of interpolation can definitely be used on many things to make smooth movement or rotation (works with angles, positions, volume, anything you can think of) and it basically means e.g. interpolate value from 1 to 2 by 1 (1=100%) to get from 1 to 2 instantly. 0 would equal 0%, 0.5 would equal 50% (so it would take 2 cycles to get to 100%), and so forth.

Actually, I tried something similar but a more complicated way and finally I ended up with a completely different solution to drag the camera :stuck_out_tongue:
Mathematical expressions really makes a different if you know how (and when) to use.

Thanks a lot for your explanation :slight_smile:

You are welcome. Surely one way is to code our own “drag camera” conditions, but using a draggable object may actually reduce some lines of code and complexity.

But whenever we want to “slowly” move from one position to another, lerp (linear interpolation) can come in useful. There are much more complex interpolations as well available on the internet, although I don’t know their functions.

On the other hand, linear interpolation is simple enough that it can be replaced with conditions, such as if x2 > x1, then increase x1 by speed, however this gives more lines of code. :slight_smile: