Help creating AI path

Get help using Construct 2

Post » Thu Mar 21, 2013 7:19 pm

Hi All,

I'm thinking about making a driving game, and I wanted to know what would be the best system to use for controlling / dictating the path of my AI vehicles.

I'd like the cars to be able to drive along in individual lanes, and possibly occasionally change lanes. I'm hoping to make a selection of both straight and curved roads, so the AI cars will also need to be able to follow curved paths.

I was wondering if I could use the Pathfinder behaviour to control the movement of vehicles, but wasn't sure if this would work. So far I've only seen pathfinder examples which use a grid system, and I would need vehicles to sometimes move along a nice smooth curved road.

Can anyone could offer me some advice?

Thanks
B
8
S
2
G
1
Posts: 63
Reputation: 880

Post » Fri Mar 22, 2013 5:01 pm

Anyone please?
B
8
S
2
G
1
Posts: 63
Reputation: 880

Post » Mon Mar 25, 2013 8:29 am

Bump, anyone?
B
8
S
2
G
1
Posts: 63
Reputation: 880

Post » Mon Mar 25, 2013 9:17 am

Not sure if this is the easiest thing to achieve just yet, especially if you want the cars to react to other cars. Using the path finder, you could have key points around the track which your cars will target as the destination, and then when they get close enough to the next point, the destination changes.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 929
Reputation: 9,356

Post » Mon Mar 25, 2013 3:17 pm

Thanks for the advice @AnD4D. I wasn't sure, but can PathFinder also be used for curved motion as well as straight lines?
B
8
S
2
G
1
Posts: 63
Reputation: 880

Post » Tue Mar 26, 2013 12:47 am

Pathfinder will use whatever the shape of the "passable" terrain is. If you have solids blocking in a circular or curved path, then it will follow that shape... but you will need to make them somewhat narrow to keep them from cutting corners and taking a straight line where possible as the logic looks for the shortest path around the solid blocks and a straight line is always shortest...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Tue Mar 26, 2013 8:37 am

Thanks @BluePhaze, for the useful information.
B
8
S
2
G
1
Posts: 63
Reputation: 880

Post » Wed Mar 27, 2013 12:12 am

I whipped up a demo using nodes to define multiple paths (lanes) for cars to follow. The cars will change lanes every few seconds.

Demo
Annotated Capx

I hope this helps.
B
44
S
13
G
7
Posts: 338
Reputation: 10,379

Post » Wed Mar 27, 2013 5:10 pm

Hi @zatyka,

This is a fantastic example, thanks very much!
B
8
S
2
G
1
Posts: 63
Reputation: 880


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests