0 Favourites

How do I control the zoom limit of the camera?

  • Hi everyone, first of all, and thank you all for your help.

    I've been working on a code for the camera to follow both players on the screen, zomming in and out as they get closer or further away from each other.

    This is the code i used:

    Now there's three things i need to fix:

    1- Whenever the sprite plays an animation (for example: punching), the camera kinda zoom's a lil bit quick and goes back.

    2- When the players are on the screen limits away from each other, the blank space around the screen, appears... wich that leads me to the next question.

    3- How can i give the zoom a limit? For both, close and near views?

    Thank you all guys, you're great!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 1: I might consider finding a way to do this all without including the player/enemy widths. It sounds like your frames are different and that's causing the issues.

    2-3: You can use clamp to force it to stay within a certain range. That will give a lower and upper limit. If you're trying to just make it not zoom so far the edges of the map show, you could add a condition that compares the edge of your layout to the viewport edge. Don't zoom out any more if they're too close, for instance. I'd type out psuedo-code for that, but it's tough without knowing your layer and layout settings, but I think you should be able to whip something up from that.

  • Thank you so much! I forgot to tell you it worked!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 39,784
lucasgc1's avatar
lucasgc1
Unread hot topic
99 10,155
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,736
MPPlantOfficial's avatar
MPPlantOfficial