Math - Camera boundary angle

0 favourites
  • 7 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • I'm terrible at math and it is already quite late so could someone point me to the right direction with this.

    Actually not object but screen center

    So for short I would like to restrict camera from going over that line (scrollx,scrolly)

  • Ok well this should work.

    Is between values:

    angle(point1.x, point1.y, point2.x, point2.y)-angle(point1.x, point1.y, screen.x, screen.y)

    Lower bound -180

    Upper bound 0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What is the effect you are trying to achieve? I don't think I have a clear view, because there is the scroll to behavior which to me sounds the same thing: the camera never leaving the center point.

    Could you explain exactly what it is you're trying to accomplish? Like the final goal that is?

  • roracle, That was quite bad explanation. I am restricting camera from going out from isometric map.

  • I'm making two assumptions here:

    1) you want the camera to operate solely within the lower triangular area.

    2) Your Layout is in 16:9 aspect ratio eg 960X540 **

    using trigonometry:

    Calculate the diagonal angle to be: 29.358 (trust me) we'll call this 'a'

    from that we can use the tangent of the X value to set the Y value to draw the hypotenuse (your diag line)thus:


    So to fall within the triangular area you want the coordinates must be in the range:

    camera.Y>camera.X*(0.5625) {0.5625 == tan 29.358}

    So the short answer is:


    Hope this makes it easier.

    ** Adjust the angle if different aspect ratio

  • bertie Booster, Actually that original post name doesn't make a lot of sense anymore

    This picture represents the layout and that isometric map is half the height of that.

  • Ok my camera now works, but it is really ugly system. Specially for right side. And I leave this unsolved for now since I'm not sure about that aspect ratio thing.

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