Pathfinding AI problem...

Just started using Construct 2? Post your questions here

Post » Tue Dec 06, 2016 9:06 am

I know I'm probably making some fatal flaw here, but I can't get my enemy sprite to follow my player around. When I first set up all of the specifications it was actually working, now I'm not sure what I've done, but what happens now is the enemy sprite has LOS on me and will only move to my original spawn location on the layout, not me or where I move to, and stop moving all together.

This is what the event sheet looks like:
System - On Start of Layout
EnemySprite has LineofSight to Player / Find path to (Player.X, Player.Y) (tried adding Clear PathFinding Obstacles, see if it made any difference)
EnemySprite - On PathFinding path found - Move along path

The sprite's LoS properties are: 360 cone of view / range: 400
B
6
S
3
Posts: 9
Reputation: 568

Post » Tue Dec 06, 2016 12:15 pm

Alright, the problem here is the following:

  • The action Find path only triggers once when you put it under On Start of Layout
  • This means that the path is being calculated only once, being on start of layout

To fix this, you need to call Find path regularly.
Don't call it every tick, that would be too CPU consuming. Call it every 1 or 2 seconds, that should work.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Post » Tue Dec 06, 2016 10:37 pm

I usually Google things I need information on and it wasn't yielding much for certain things so I was creating topics. I think I'll search in tutorials in the future. I had a small issue with this Pathfinding, but it's fixed now. Thank you, I appreciate both of your responses.
B
6
S
3
Posts: 9
Reputation: 568


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests