Top-Down Car AI

0 favourites
  • 6 posts
From the Asset Store
Set of tiles to create a map for top-down games with island theme
  • Hello,

    I have currently been deigning a cops and robbers game. I want to do cars that drive around, but will stay on their side of the road and will not crash into each other. I am not sure what the best solution to this would be. For movement, I was thinking about Move To, Pathfinding, or Car. There are intersections, and there will be multiple cars. The Timeline might work, but I would have to do a new timeline for each car, and if there are ten levels with three to five cars each. . . well, that would be a lot. I need to do the movement before I can make them stop for other cars.

    So, bottom line for right now is: How can I make cars that will move along the road, turn a set or preferably random direction, and will stay on their side of the road? I have attached a picture below.

    Thank you

  • A bunch of invisible sprites all over the roads then set cars to move to those and turn towards those.

    Every time it reaches one of those ( at an intersection for example ) make it choose another one that is straight, left or right and move toward that one.

    Then each car can choose these. Avoiding car collisions will require more thinking, depends how far you are willing to go with it. May be faster to use timelines even if you have to do one for each car.

    I am wrapping up a top down racing game, so I do not have to deal with intersections, but creating realistic car AI where cars moving at different speeds go around each other and behave realistically if they do crash into each other is not something you can do easily.

  • Thank you. I might have to give that a try.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That worked. I game the waypoints instance variables and the car added a waypoint for each one ordered ascending. See the pictures:

  • You can add a second set of points and let a car choose to switch or remain on its current path to that set when at intersection. That will give you more variety

    The rest of the logic should be the same, just switch from pointA to pointB path

  • That sounds like it would work. I now have to make them stop or go around if there is a crash. Hopefully that won't be too hard.

    Thanks a lot!

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