How do I set layer zoom relative to objects coordinates.

Get help using Construct 2

Post » Mon May 11, 2015 1:52 pm

Hey there, i'm trying to make a dynamic zooming camera for a 4 player game. (it's an arena/stadium type game)

The idea is that the camera is always framing the 4 players with an acceptable margin. So if the players are near each other the layer zooms in, if the players are far apart, they layer zooms out.

If we could do this without the camera going outside the layout it would be great.

I've been trying to do this for a while now, but I haven't been able to produce any proper results yet. My best effort so far was to "pick the distance from the player who was farthest from the camera coordinates", and use that to manually set the zoom values on a cosp formula using lower and higher zoom values, but it's crap and doesn't work like it should, though sometimes it looks like it's going to Dx

i searched around the forums, and saw a couple post where they where using the distances of the players, compared to the window's size, but i wasn't able to make that work either. I'm assuming i'm really not good at scaling the damn layers (i need to scale only a couple of layers, and not all of them in the layout)...

anyway, any help would be really appreciated T_T
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Mon May 11, 2015 6:10 pm

Have you tried giving each of the players the scroll to behavior ?
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Mon May 11, 2015 7:43 pm

@lennaert thanks, but that's really not what I need. I'm looking for a way to dynamically zoom in and out with the character change their distances to each other, the scroll to behavior has nothing to do with that, it's used to tell the game where to center the camera. thanks anyway =)
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Mon May 11, 2015 7:46 pm

Your question is almost the same as the one in this thread from yesterday, it might help:

calulate-higest-distance_t130342
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 11, 2015 9:34 pm

Sargas wrote:@lennaert thanks, but that's really not what I need. I'm looking for a way to dynamically zoom in and out with the character change their distances to each other, the scroll to behavior has nothing to do with that, it's used to tell the game where to center the camera. thanks anyway =)



edit: sorry, you meant relative .. misread some, my approach with all objects with scroll would center the camera automatically in their midst
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Mon May 11, 2015 10:54 pm

@LittleStain as a matter of fact, I had studied those post extensively, but they don't work the way i need to. In my game there can be 2 to 4 players and I haven't found a way to adapt those examples to my current needs =(
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Mon May 11, 2015 11:35 pm

It shouldn't be hard..

The explanation is there to get the x-coordinates and y-coordinates to use in the zoom example from the referenced thread..
In that example x and y of player1 are used and x and y of player2
instead of using them you use the lowestx,lowestY and Highestx,highestY

if there are two players, three players or four players shouldn't make a difference..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue May 12, 2015 12:54 pm

@LittleStain if it wasn't hard, or if I was able to, i wouldn't be asking for help =(

Do you know how to apply the logic to what I need? could you help me please?
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Tue May 12, 2015 1:05 pm

Sargas wrote:@LittleStain if it wasn't hard, or if I was able to, i wouldn't be asking for help =(

Do you know how to apply the logic to what I need? could you help me please?


You should apply it like I explained above, but if I have time I will adjust the capx for you..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue May 12, 2015 1:18 pm

Sorry it took so long to adjust the capx, I should have been able to do it within 10 minutes..

https://dl.dropboxusercontent.com/u/485 ... ayers.capx

I know it isn't perfect, yet..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: 25games, jatin1726, kiki4construct and 37 guests