Selecting from two objects based on distance

For questions about using Classic.

Post » Mon Sep 13, 2010 7:26 am

Ok, so here's what I'm trying to do.

I have two of the same sprite, (ally) and an enemy sprite (enemy).
The enemy sprite has line of sight and RTS movement.
I want to get the enemy to choose the ally that is closer.
The ally has a family (good) that the enemy is looking for.

What is happening is that the enemy sprite always goes to one ally.
Even if the other ally is closer.

It seems like the enemy is choosing the ally with the higher "priority," always.
How can I fix this?
(Get the enemy to choose the closer ally to move to)

I think it has to do with which ally I'm telling it to go to.
B
1
G
2
Posts: 2
Reputation: 629

Post » Mon Sep 13, 2010 7:59 am

There is a distance between two points event under math, which is under system which will help. Give the allies a private variable that is set to the distance between them and the enemy, and have the enemy pick the lowest one.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Mon Sep 13, 2010 11:34 pm

I ended up doing something different, but you pointed me in the right direction.
Thanks for the help!
B
1
G
2
Posts: 2
Reputation: 629

Post » Mon Sep 13, 2010 11:39 pm

there is also a pick closest condition for sprites
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests