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
84
S
12
G
9
Posts: 99
Reputation: 9,508

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
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Thu Jul 21, 2011 2:13 am

Perfect thank you. That is a fair amount simpler.
B
84
S
12
G
9
Posts: 99
Reputation: 9,508


Return to Construct 2 General

Who is online

Users browsing this forum: Avengium, MadSpy and 11 guests