enemy AI, distance calculation

For questions about using Classic.

Post » Wed May 23, 2012 11:33 am

Man... stuck again.
I'm trying to trigger an event with
distance(herosprite.x,herosprite.y,enemy.x,enemy.y)lower or equal to 300
Nothings happening. The only thing I can think of is that "herosprite" is a global sprite located on another layout, and I'm not clear yet how different instances of an object effect things...
Anyway, here is the CAP, I'm too tired to think about it anymore... Hope you guys can help!

CAPSeanyD2012-05-23 11:34:18
B
2
Posts: 4
Reputation: 258

Post » Wed May 23, 2012 7:10 pm

Make the objects herosprite and hero non-global, and copy>paste them in the other layout. That worked for me.
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Wed May 23, 2012 8:22 pm

I see nothing happening because must use a 'for each Sprite37' in the ES of layout4, event 5. This due to, there is more than one instance of sprite 37 and the event picks all at once, and you must check up one by one.

Try that above or try adding before checking condition a 'pick closest to herosprite', 'enemy' sprite condition, this should work properly.

EDIT: this i speak about:
+ Sprite37: Pick closest to: compactorhero.X, compactorhero.Y
+ System: distance(compactorhero.X,compactorhero.Y,Sprite37.X,Sprite37.Y) Lower or equal 300
-> Sprite37: Set 'aggro' to "yes"

or

+ System: For each Sprite37
+ System: distance(compactorhero.X,compactorhero.Y,Sprite37.X,Sprite37.Y) Lower or equal 300
-> Sprite37: Set 'aggro' to "yes"
Yaottabyte2012-05-23 20:27:04
B
4
S
1
G
1
Posts: 69
Reputation: 863


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest