How do I Zoom-in Camera smoothly?

0 favourites
  • 6 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • using Lerp to try to zoom in:

    Set Layer 6 Scale to 
    lerp(LayerScale(6), GameCameraZoom,1*dt)[/code:y3kmy7vo]
    
     but the lerp takes a long time (wall clock) to actually end (even though it looks like it stopped).. and i'd rather not spend the processing on unneeded calculations..
    
    anyone doing smooth zoom ins/outs differently?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use global variable "Scale" :

    Scale = 0 ------------ lerp(layoutscale, 0.6, 1*dt) - "Zoom out"

    Scale = 1 ------------ lerp(layoutscale, 1.2, 1*dt) - "Zoom in"

  • A0Nasser this is what I am already doing.

    If you watch the LayerScale() or LayoutScale variables you'll see them take a few minutes to stop calculating. When it gets close to the desired scale (i.e 0.6) It starts slowing down around 0.69999991. You can't see it on the screen really, but I don't like that, it seems like a messy practice and a potential leak. Especially if user spams the zoom...

  • The "magicam" plugin is perfect for things like that.

  • Instead of using lerp like that, use it the intended way:

    Lerp(min_scale, max_scale, percentage/100)

    Where min scale is the minimal scale, max scale is the max scale, and you make percentage varies from 0 to 100 to vary from min scale to max scale. (For exemple when you are zooming in, set percentage to clamp(percentage+100*dt, 0, 100) will zoom from min to max in 1 second)

  • Aphrodite brilliant! thanks! that's exactly what I need.

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