# I wanna pin my player on the closest imagepoint!!!

Get help using Construct 2

### » Mon Oct 07, 2013 2:21 pm

Thank you for coming.

I wanna pin my player on the closest imagepoint of an object.

Top down game where every object rotates.

I have tried offset position without success, but now i am willing to use: imagepointX(N.)-player.X, take the smallest X.

The problem is, i don't know how to build it up on the events...
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

### » Mon Oct 07, 2013 2:27 pm

How many imagepoints are there?

You can get the distance with distance(player.x,player.y,sprite.imagepointX(),sprite.ImagepointY())

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

### » Mon Oct 07, 2013 2:29 pm

@LittleStain
like 8, all of them inside the object.

About the distance, the problem is returning in with the closest.breackzin2013-10-07 14:37:38
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

### » Mon Oct 07, 2013 2:59 pm

a creative way would be giving the object instance variables.

Dis1i, Dis2i, Dis3i, etc. and setting them to the distance to the player.

then you can do a sytem compare 2 for every one:

min(Dis1i,Dis2i, etc.) = Dis1i -> player pin to imagepoint1
min(Dis1i,Dis2i, etc.) = Dis2i -> player pin to imagepoint2

There are probably much better ways, but I'm trying to be creative here.
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

### » Mon Oct 07, 2013 3:16 pm

A much simpler solution would be to loop through each objects image points, testing its distance from the player, and then setting/pinning the player to the one with the shortest distance.

Capx
B
67
S
21
G
8
Posts: 341
Reputation: 12,560

### » Mon Oct 07, 2013 3:25 pm

@zatyka, yep, like I said, there are much better ways.
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

### » Tue Oct 08, 2013 9:59 pm

@LittleStain and @zatyka
My most sincere thanks.
B
7
S
3
G
1
Posts: 154
Reputation: 1,812