How do I update path of enemy with "Pathfinding"

Just started using Construct 2? Post your questions here

Post » Thu Feb 12, 2015 4:39 pm

Hello. I'm creating a tower defense game where I make maze for enemies by myself. But there is a problem: when enemy is moving on screen, it ignores recently built blocks and moves trough them. Can you help me to fix it? I can't provide a sample because I can't paste links.
B
29
S
14
G
6
Posts: 160
Reputation: 5,752

Post » Thu Feb 12, 2015 5:00 pm

When you need to update the possible path, you need to use the "Regenerate Obstacle Map" or "Regenerate Region Around Object" actions. Remember, the map is only created at start of the layout unless you regenerate it with one of these actions. Also, regenerating the map is very CPU intensive and could cause slow down in your game if you are doing it often.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Thu Feb 12, 2015 5:14 pm

Image

Thank you for your reply. Here is the screen. What do I need to change here?
B
29
S
14
G
6
Posts: 160
Reputation: 5,752

Post » Thu Feb 12, 2015 7:20 pm

Event 4 move the Regenerate action before the Find Path action.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Thu Feb 12, 2015 8:01 pm

Thank you very much! It was bad mistake, I've been working with Construct Classic for about 2 years. Now it works ("wait" is to find path after regenerating):

Image
B
29
S
14
G
6
Posts: 160
Reputation: 5,752

Post » Thu Feb 12, 2015 9:09 pm

I believe you can make that wait 0.0 and it will still work, as it won't run until the next step, if I'm remembering correctly.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Thu Feb 12, 2015 9:45 pm

I made and it doesn't work. It works at least with 0.03 seconds.
B
29
S
14
G
6
Posts: 160
Reputation: 5,752

Post » Thu Feb 12, 2015 9:51 pm

Sorry to conjecture when I'm not on my laptop at the moment, but, isn't there a trigger for "on regenerate obstacle map" that you can use instead of the wait function?
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Thu Feb 12, 2015 10:15 pm

I was trying to find it too, but there is no such triggers. Only "On path found". Wait is good solution here I think, because you wait just 30 MS.
B
29
S
14
G
6
Posts: 160
Reputation: 5,752

Post » Fri Feb 13, 2015 1:26 am

You will be better off, just regenerate the region around where the new obstacle is. It will improve performance.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests