Math - Camera boundary angle

Get help using Construct 2

Post » Fri Feb 21, 2014 11:22 pm

I'm terrible at math and it is already quite late so could someone point me to the right direction with this.

Image
Actually not object but screen center

So for short I would like to restrict camera from going over that line (scrollx,scrolly)
Last edited by Katala on Sat Feb 22, 2014 11:30 am, edited 1 time in total.
B
34
S
9
G
3
Posts: 517
Reputation: 5,226

Post » Sat Feb 22, 2014 1:24 am

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
B
34
S
9
G
3
Posts: 517
Reputation: 5,226

Post » Sat Feb 22, 2014 1:34 am

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?
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Sat Feb 22, 2014 9:46 am

@roracle, That was quite bad explanation. I am restricting camera from going out from isometric map.
B
34
S
9
G
3
Posts: 517
Reputation: 5,226

Post » Sat Feb 22, 2014 10:31 am

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:

Y=X*tan(a)

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:

camera.Y>camera.X*0.5625

Hope this makes it easier.

** Adjust the angle if different aspect ratio
B
7
S
2
Posts: 93
Reputation: 797

Post » Sat Feb 22, 2014 11:25 am

@Bertie Booster, Actually that original post name doesn't make a lot of sense anymore :)

Image

This picture represents the layout and that isometric map is half the height of that.
B
34
S
9
G
3
Posts: 517
Reputation: 5,226

Post » Sat Feb 22, 2014 12:18 pm

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.
B
34
S
9
G
3
Posts: 517
Reputation: 5,226


Return to How do I....?

Who is online

Users browsing this forum: 25games, Artcadev, grodrigues and 23 guests