police chase

0 favourites
  • 5 posts
From the Asset Store
Template for a police car chase game, fully documented in comments and video
  • I am trying to create police in my game that can pathfind somewhat, so that they can find you in a large map and try to crash into you. An example is the game Most Wanted.

    However, all I have now is cars driving into walls and hoping to reach you sooner or later.

    I can do that with pathfinding, but am not sure how to do this with physics. I have already tried setting up a waypoint system but it isn't working to well.

    Here's what I've got...

    https://drive.google.com/open?id=14OYAyPJUAVE2Lfkn0Ny2ggdSkBe-T8wP

  • Navigating a sprite with Physics through a complex maze is difficult even when you control it manually. I'm afraid doing the same with events is pretty much an impossible task.

  • Would it work with something cheaper, say, following the player through the maze?

    Here is my idea:

    1. find the nearest waypoint and store a counter variable / UID

    2. move toward it

    3. if it sees a waypoint with a higher value counter variable / UID, set the counter variable / UID to the new value

    4. repeat steps 2 and 3 forever

    I started working on a simpler version outside of the game, just to see if it works. So far, no luck

    https://drive.google.com/open?id=1LJGh0cS96j26RpE_QN0nJMU78JY8bZT5

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With Physics the chances of the sprite getting stuck somewhere are like 99%

    EDIT: Oh, I see you are using Car behavior now. It's not much better than Physics in this case, because car has inertia, it can't make sharp turns and takes time to stop. So it will also get stuck often.

    The easiest and most obvious solution is to use pathfindind. If you have a predefined path, you can move sprite from one point to another using behaviors like MoveTo, Bullet, Tween. Also, see this post for some other examples.

  • First of all, I figured it out, but not perfectly by any stretch.

    With Physics the chances of the sprite getting stuck somewhere are like 99%

    Well, only somewhat. I am not making a maze, just a very large playing field with many open areas and ways to get around. So, I don't need it to be perfect, especially if there are enough enemies. And yes, I am still using physics, but I just needed simpler steering to figure this out.

    Also, I figured it out. The car "followers" get stuck (it doesn't back up) but other than that you can check out a working project. The only issue keeping it from working was I wasn't picking all the Waypoints. Now it works pretty well.

    (Note: this is commented if ever needed for future use)

    https://drive.google.com/open?id=1LJGh0cS96j26RpE_QN0nJMU78JY8bZT5

    And then with physics:

    https://drive.google.com/open?id=14OYAyPJUAVE2Lfkn0Ny2ggdSkBe-T8wP

    Thanks for all the help though!

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