How do I Zoom-in Camera smoothly?

Get help using Construct 2

Post » Sat Jun 21, 2014 3:52 am

using Lerp to try to zoom in:

Code: Select all
Set Layer 6 Scale to
lerp(LayerScale(6), GameCameraZoom,1*dt)


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?
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Sat Jun 21, 2014 4:43 am

Use global variable "Scale" :

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

Scale = 1 ------------ lerp(layoutscale, 1.2, 1*dt) - "Zoom in"
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,165

Post » Sat Jun 21, 2014 5:13 am

@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...
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Sat Jun 21, 2014 7:33 am

The "magicam" plugin is perfect for things like that.
plugin-magicam-for-c2-alpha-6-5-1-8-14_t74513?&hilit=magicam+plugin
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Sat Jun 21, 2014 12:45 pm

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)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Sat Jun 21, 2014 2:50 pm

@Aphrodite brilliant! thanks! that's exactly what I need.
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests