How do I make an enemy pathfind to a player

Just started using Construct 2? Post your questions here

Post » Mon Jun 01, 2015 4:59 am

I just can't figure it out or find the answer. I have the enemies pathfinding to the player but they always go to where the player was before creating a new path, I want them to alwas go towards the player and not crash into walls. There will also need to be multiple instances of the enemy sprite.

Thanks for looking, blohod.
B
7
S
1
Posts: 18
Reputation: 461

Post » Mon Jun 01, 2015 11:48 am

If your player is moving when the enemy is moving towards him , it's normal that he would not follow him.
You must recalculate the way.
Image Image
B
25
S
14
G
136
Posts: 876
Reputation: 71,005

Post » Mon Jun 01, 2015 12:16 pm

could move toward player.x and player.y
regen map
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,753

Post » Mon Jun 01, 2015 7:09 pm

Try this:

System >> Every 0.25 seconds | Enemy >> Find path to Player

Enemy >> On path found | Enemy >> Move along path

This makes it so the enemy updates the path every 1/4 of a second.

Does it help?

@theman3446~
Life is good. Have another piece of chocolate.
B
15
S
3
G
1
Posts: 28
Reputation: 1,133

Post » Mon Jun 01, 2015 7:17 pm

Also, you need to change the max speed of all of the enemies to different values so that they will not overlap and look like just one enemy.

@theman3446~
Life is good. Have another piece of chocolate.
B
15
S
3
G
1
Posts: 28
Reputation: 1,133

Post » Tue Jun 02, 2015 10:28 am

theman3446 wrote:Try this:

System >> Every 0.25 seconds | Enemy >> Find path to Player

Enemy >> On path found | Enemy >> Move along path

This makes it so the enemy updates the path every 1/4 of a second.

Does it help?

@theman3446~


Thanks, sound good, the different speeds idea sound good too.
B
7
S
1
Posts: 18
Reputation: 461

Post » Tue Jun 02, 2015 2:32 pm

You're welcome!
Life is good. Have another piece of chocolate.
B
15
S
3
G
1
Posts: 28
Reputation: 1,133


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests