How do I zoom in the camera to an object on a condition?

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi all,

    I'm a Unity dev trying to use construct 3 for my new game. I want to zoom in to an object on screen when a bool is set to true and zoom out to how it was originally when set to false. I tried having a boolean and when set to true. I did System.scrollto (lerp(scrollX, object.Y, scrollSpeed * dt) (lerp(scrollY, object.Y, scrollSpeed * dt) and System.layoutscale lerp to 1.5. But it acts wierd. Doesn't work all the time..

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is what I've tried. I have a dummy object camera target which has the scroll to behaviour.. And I move this dummy object to the player object's position when zoomToPlayer bool is set to true and move it back to 0,0 when it is false. I also lerp the layout scale to 2 when zoomToPlayer is true and back to 1 when false.

    But it seems this only works when the player is on the right and bottom relative to the camera target object. It doesn't work otherwise. What am I missing? :(

  • But it seems this only works when the player is on the right and bottom relative to the camera target object. It doesn't work otherwise.

    Does zoom work? Or both camera movement and zoom are not working?

    Try enabling "unbounded scrolling" in layout properties. Also check parallax setting on layers.

    By the way, instead of lerping you can use MoveTo behavior to smoothly move the camera with nice acceleration and deceleration effect. And Tween behavior (value) to zoom in/out.

  • > But it seems this only works when the player is on the right and bottom relative to the camera target object. It doesn't work otherwise.

    Does zoom work? Or both camera movement and zoom are not working?

    Try enabling "unbounded scrolling" in layout properties. Also check parallax setting on layers.

    By the way, instead of lerping you can use MoveTo behavior to smoothly move the camera with nice acceleration and deceleration effect. And Tween behavior (value) to zoom in/out.

    Hi. Zoom works.. But the camera movement doesn't. Unbounded scrolling is enabled. I have just one layer in the layout.

  • Now I've disabled the layout scale and replaced lerp to moveTo behaviour for the camera target. It still acts weird. Only works when the player is on the right and bottom relative to the camera target object. It doesn't work otherwise. Same as before

  • You can see the camera movement works only when the player object is on the right bottom relative to the camera target.

    https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExaGk4eTM4Nmh6cTk5MnUxdnVxcHVoZHoxNG50cDhtZWx4ODk3aTl5YSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Tng08bJKWJTxX6wBMD/giphy.gif

  • I figured it out.. It was because I had Bound to layout behaviour on the camera target object and the player object was going beyond that..

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