How do I create a specific movement for each instance ?

Get help using Construct 2

Post » Sun Jan 17, 2016 1:27 pm

How do I create a specific movement for each instance of a family ?
I'm working on a ranged ennemy for a "rogue-like game".
here's his how he's working:

Code: Select all
every 0.3sec 
for each EnnemyRanged -> Set EnnemyRanged.DistanceToPlayer=sqrt((self.X - Player.X)^2 + (Self.Y-Player.Y)^2)
   ( EnnemyRanged.DistanceToPlayer < EnnemyRanged.SafeDistance ) -> Set EnnemyRanged.focus 2
Else   ( EnnemyRanged.DistanceToPlayer >= EnnemyRanged.SafeDistance and   ( EnnemyRanged.DistanceToPlayer <= EnnemyRanged.DetectionRange ) -> Set EnnemyRanged.focus 1
Else ( EnnemyRanged.DistanceToPlayer > Ennemy.DetectionRange ) -> set EnnemyRanged.focus 0

focus= 0 -> stop
focus=1 -> find path to player.x,player.y and move along
focus=2 -> enemy flee (too long to write)


I've tried to use "for each instance" and "pick by UID" but seem like it doesn't work at all.
when i run my game it's the nearest ennemy who defined the movement of all the instances of this family, for instance all the ennemy go to the same place.
I want to each instance to determinate where he must go...
B
5
S
1
Posts: 21
Reputation: 419

Post » Sun Jan 17, 2016 1:55 pm

post the capx or a screenshot of the events?
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446


Post » Sun Jan 17, 2016 5:15 pm

"Find path" is an asynchronous operation - it takes time to calculate. You can't call "Move along path" right away. Add "On path found" and then do "Move along path".
ImageImageImage
B
71
S
21
G
231
Posts: 3,695
Reputation: 129,366

Post » Mon Jan 18, 2016 7:27 am

ok i had this event but it still doesn't work.
B
5
S
1
Posts: 21
Reputation: 419

Post » Mon Jan 18, 2016 5:58 pm

Can you re-post with the new events?
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Mon Jan 18, 2016 6:23 pm

B
5
S
1
Posts: 21
Reputation: 419

Post » Mon Jan 18, 2016 6:32 pm

Maybe try moving event 42 to 51 as a subevent of 41, so you know only one Enemy is picked at a time.
ImageImageImage
B
71
S
21
G
231
Posts: 3,695
Reputation: 129,366

Post » Mon Jan 18, 2016 8:16 pm

Done but it still doesn't work...
B
5
S
1
Posts: 21
Reputation: 419

Post » Mon Jan 18, 2016 9:06 pm

You'd have to post a CAPX then to get better help.
ImageImageImage
B
71
S
21
G
231
Posts: 3,695
Reputation: 129,366

Next

Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 57 guests