# Get Nearest in Orthographic game

Get help using Construct 2

### » Tue Mar 12, 2013 6:57 pm

I was wondering what is the best way to make the function Get Nearest to work not in circle but in elipse for faking perspective in ortho game?
Thanks
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

### » Tue Mar 12, 2013 7:01 pm

Check for overlap using an invisible ellipse shaped sprite?
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Tue Mar 12, 2013 8:04 pm

Nice :)
It may work in my case but I want to make a woodcutter searching for the nearest tree to cut. Maps could be quite big so the elipse will get too huge.
If there's another way i would prefer it.
Anyways i'll keep that in mind im sure i'll use it in other cases. Thanks.
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

### » Tue Mar 12, 2013 8:25 pm

@Pakost the ellipse only has to be as big as the range of the area you want to look in... and you pin it to the player maybe so that it stays with them...
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Tue Mar 12, 2013 8:26 pm

For each tree, pick the smallest relative distance between the woodcutter by using a modified dy (assuming the major axis of your ellipse is on the x axis).

Modified dy = (Woodcutter.Y - Tree.Y) * Ellipse.Width / Ellipse.Height

Distance = (dx^2 + dy^2)^-2

You could even just pick the smallest of the Abs(dx) + Abs(dy), since the actual distance value is not really needed.

A function returning the UID of the closest tree would work great !
B
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

### » Tue Mar 12, 2013 8:42 pm

@Magistross great idea
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Tue Mar 12, 2013 8:57 pm

I cooked something in a hurry there.
B
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

### » Wed Mar 13, 2013 1:53 am

Works like a charm.
It took me some hours to understand and implemend it but finally i did.
Thanks both of you guys, and Magistross thanks for the example. Couldnt do it without it.Pakost2013-03-13 01:54:40
B
12
S
3
G
1
Posts: 120
Reputation: 1,829