Smooth mouse view

This forum is currently in read-only mode.
  • I will try to explain...

    I am making a RTS game, and I need a smooth camera movement (moving around with no imediately action or fast action, need smooth camera) like in other RTS games like: Warcraft, Starcraft etc. or like 3D tool programs, when you hold the right button and move, it's like an acelerating method.

    I am having trouble with the "Center view on me", because it's too fast, and it is imediately, i need something more dynamic. Can anybody help-me pls?

    Thanks and sorry for my english!

  • One trick for smooth scrolling is to scroll always to the halfway of current point and target point. This way it scrolls first wast and then slows down when appoarching the target point.

    Pseudocode:

    scroll x to current.x + ((target.x - current.x )/2)

    scroll y to current.y + ((target.y - current.y )/2)

    If you want more snappy and quick scrolling, just change the 2 to some bigger number.

  • Sorry but can you make a little example?

    I am trying use your code in construct, but it doesn't work for me

    ps: I need the camera to follow the mouse, but in smooth condition

    :/

    [EDIT]

    THANKS DRASA, I HAVE USED YOUR CODE CORRECTLY, IT'S WORKED PERFECTLY, THANKS!!!!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh, I made a mistake :D. The scrolling becomes actually slower when you increase the number.

    Also, I whipped up an example, but it seems there's no need for it anymore.

    http://drasa.nipponfever.net/muu/rts-scroll.cap

  • That's a good example, but it's framerate dependent. If you run at twice the framerate, you move twice as quickly towards the scroll location. That might not matter that much for scrolling, but if you want the same thing for important gameplay elements, this is the framerate independent formula:

    lerp(ScrollY, Sprite2.Y, 1 - 0.0001 ^ TimeDelta)

    0.0001 is the number to change for how quickly it goes. Smaller makes it go faster.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)