point to nearest. object

Discussion and feedback on Construct 2

Post » Thu Jul 21, 2011 12:49 am

In learning C2 I'm trying to solve simple problems to build my understanding of it's concepts.

My current problem is what is the best way to have Object A find and point at the closest Object B among many.

So far I can solve it like this


But it seems like i'm missing a concept that would make this simpler. I just don't know enough to find it.
link to .capx

Thanks.
B
87
S
14
G
9
Posts: 101
Reputation: 9,937

Post » Thu Jul 21, 2011 1:58 am

It works just fine, but you can simplify it a bit. Here's my version.

You only really need the D_shortest variable. Then, for each goal, if the current goal is nearer than the last one, look at that instead.
Scirra Founder
B
378
S
220
G
84
Posts: 23,871
Reputation: 188,207

Post » Thu Jul 21, 2011 2:13 am

Perfect thank you. That is a fair amount simpler.
B
87
S
14
G
9
Posts: 101
Reputation: 9,937


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests