Enemies on paths

Get help using Construct 2

Post » Mon Feb 04, 2013 3:14 am

Hello,

I'm pretty new to Construct but I've been playing around with it all weekend and there's just one big thing that still eludes me:

How do I put multiple instances of an enemy on different patrol paths?

I have a number of enemies in my layout and I now want them to start patrolling along fixed, pre-determined paths, I just can't figure out a way to do it.

How do I designate points on the path, how do I tell an enemy to move from point to point, how do I make sure each enemy is patrolling the right path and put them back on the right one if they get aggro'ed?

Most editors I'd used have a pre-built patrolling behavior and path builder tools so I'm unsure how to approach this.

Any help would be appreciated :)

Thanks!
B
5
Posts: 12
Reputation: 999

Post » Mon Feb 04, 2013 10:32 am

i dont know if this will help but....you could just create a sprite for the enemy's path and then set the enemy to that path using set to position.(set the enemy to pathsprite.x, pathsprite.y)
you will need to use other sprite as contact markers so that the enemy turns and such. that should work!
B
10
S
1
G
1
Posts: 74
Reputation: 1,637

Post » Mon Feb 04, 2013 12:36 pm

I recall rexrainbow has plugin for that. If I'm not mistaken it is called rex_move.

Maybe you can check it out. I havent try it so I cant tell if that is what you need.
B
21
S
5
G
1
Posts: 39
Reputation: 2,715

Post » Tue Feb 05, 2013 12:37 am

Thanks for the information!

I'll see if I can find the plugin and give it a try.

B
5
Posts: 12
Reputation: 999

Post » Tue Feb 05, 2013 1:40 am

You may also be able to use the new pathfinding behaviors in r117 and set the enemy to find a certain sprite, then when they reach it, set it to the next sprite, this way you could control your route.

Maybe have an instance variable that tracks the current/next target, and on collision with the waypoint sprite, update it to the next target...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Tue Feb 05, 2013 9:59 pm

Here's one approach - create three instance variables, to record the start waypoint, end waypoint, and current waypoint of each enemy.
Then just set each enemy to head towards their current waypoint. When they reach it, increment their current waypoint by 1. If that is their maximum waypoint, reset the marker back to their first waypoint again.


EXAMPLE CAPX
B
8
S
2
G
3
Posts: 83
Reputation: 2,668

Post » Fri Feb 08, 2013 1:26 am

I was looking at the Pathfinding behavior, i was thinking it would be my best bet, but Tanoshimis solution looks pretty good too. I'm just unfortunately dealing with a different incredibly stubborn problem so I haven't even gotten a chance to try any of this yet :(
B
5
Posts: 12
Reputation: 999

Post » Sat Feb 09, 2013 4:54 pm

Thanks to all of you, with knowledge gleaned from your suggestions I was able to build a system that automatically assigns my instances to the proper paths and tracks their progress.

Cheers!
B
5
Posts: 12
Reputation: 999


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Calfuso and 23 guests