[solved]Set layout scale by formula of distance between two points

0 favourites
  • 2 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • Can someone good at math give me a formula for how to set the layout scale to something based on the distance between two points? The layout size is 3840x3840, and the window size is 1920x1080, so when the objects are right on each other, the layout scale should be 2 max, and when they're furthest away, it should be 0.5 min.

    So far the best I have is this, except it gives the opposite scale effect I want, and zooms out too much, and has nothing else to do with the measures I need:

    Every tick: Set layout scale to distance(1CharBox.X, 1CharBox.Y, 2CharBox.X, 2CharBox.Y)/1000

    Edit: Oh, okay, I figured it out. Sorry. Was easier than I thought. In case anyone else cares:

    Every tick: Set layout scale to 1000/distance(1CharBox.X, 1CharBox.Y, 2CharBox.X, 2CharBox.Y)

    I also made a global variable called Layout_Scale that's always set to LayoutScale. Then:

    Layout_Scale < 0.5 : Set layout scale to 0.5

    Layout_Scale > 2 : Set layout scale to 2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try this:

    Set layout scale to clamp(2200/distance(1CharBox.X, 1CharBox.Y, 2CharBox.X, 2CharBox.Y), 0.5, 2)

    "2200" is the biggest distance possible on 1920:1080 screen (the diagonal).

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