How do I find a path to a moving object?

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • How do I use the Pathfinding feature to follow a moving object. So far I have this code but it just crashes my game when I click a monster outside of the basic_attack_radius variable:

  • The pathfinding behavior is very CPU intensive. In your code, you are using a loop inside which you are finding a path. This starts the process of finding a path repeatedly and you will eventually run out of processing power to complete the task so, it is no wonder the game is crashing. Have you read through the documentation and tutorials on pathfinding? If you had, you would see this is not how to use the behavior.

    There is a really good tutorial on combining 2 behaviors to get an enemy to chase the player:

    https://www.scirra.com/tutorials/474/pa ... e-of-sight

    Read through it. You may find an easy way to do what your are trying to do. Also, make sure to read all the documentation on the pathfinding behavior in the manual and check out a couple other tutorials.

    I hope that gets you what you need and good luck with your project.

  • how about this: (kamikaze enemies move towards you, that's a instance variable) and other move toward where they were randomly assigned.

    if your obstacles are static you can remove regenerate obstacle map. also make sure your item that you follow isn't a obstacle.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The pathfinding behavior is very CPU intensive. In your code, you are using a loop inside which you are finding a path. This starts the process of finding a path repeatedly and you will eventually run out of processing power to complete the task so, it is no wonder the game is crashing. Have you read through the documentation and tutorials on pathfinding? If you had, you would see this is not how to use the behavior.

    There is a really good tutorial on combining 2 behaviors to get an enemy to chase the player:Read through it. You may find an easy way to do what your are trying to do. Also, make sure to read all the documentation on the pathfinding behavior in the manual and check out a couple other tutorials.

    I hope that gets you what you need and good luck with your project.

    Thanks for the information. I'm going to do more in-depth research into the pathfinding behaviour. One question, I thought about the processing intensity for the CPU, that's why I added the wait action but it doesn't work, can you shed some light on that?

  • Take a look at this:

    https://www.scirra.com/tutorials/723/us ... t-in-loops

    The wait only stops the follow path event. The loop continues processing the next iteration immediately.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)