As a fan of Car Wars, The Road Warrior, Spy Hunter and Death Race, I want to arm and armor a squad of post-apocalyptic muscle cars then send them into the wasteland to challenge gangs of jury-rigged monstrosities-on-wheels fighting over gasoline and spare parts.
Engines like Unreal (and Unity) are available for free and it's easier than ever for inexperienced developers to create games. With no eagerly anticipated announcements forthcoming, like any smug mature gamer with a programming background I thought, "How hard could it be?"
As we're going to find out, fairly hard.
"Simple" Vehicle Movement
The first feature to tackle is point-and-click movement. Instead of directly controlling a single vehicle, we want a squad of vehicles to drive themselves to a specified destination.
I assumed it would be as simple as importing a vehicle from one of the examples, build a Behavior Tree Task and send it a MoveTo.
Except that pawns using the WheeledVehicleMovement component don't respond to MoveTo. They respond to Throttle, Steering and Handbrake. So not only do we have to tell it where to go, but how to get there.
The typical approach to racing game AI is to pre-build waypoints into a circular track. That won't work for this game due to the open-world style maps. We need to tell a vehicle to move from anywhere to anywhere. Fortunately, we can still use Unreal's NavMesh intended for character pawns. The FindPathToLocationSynchronously function simply needs Start and End vectors. The result is a NavigationPath object, which includes an array of Path Point vectors.
Who says A* Pathfinding is complicated?
Now we can build a short Behavior Tree Service that recalculates a path from the vehicle's location to its destination. Finally, have the vehicle always steer toward the next waypoint, NavPoints[1], and set the throttle to 1.0 (for now). Our logic so far looks like:
I thought you said this was hard?
Next time, we'll make the throttle smarter and make use of the handbrake.
Hey bro, do you can to explain me how you did it, please? Or give me an example of logic. I make strategy, and I can not configure the behavior of inorganic units, vehicles for example. I searched all the internet and found you :) Sorry for my english, it's not my native language, very hope on your help. Many thanks and good luck.
ReplyDeleteWhich part are you having difficulty recreating?
DeleteHi!
ReplyDeleteCare to show how you calculated the steering, I presume that is the part with which most people have difficulty when recreating the behavior.
Thank you and have a Happy New Year! :)
The initial steering calculation came from Peter L. Newton's Unreal Community post on AI: https://forums.unrealengine.com/showthread.php?25073-UPDATED-5-16-A-I-Templates-Bot-Car-amp-Flying-AI .
ReplyDeleteHere's a snapshot of the blueprint I use: https://picasaweb.google.com/lh/photo/xYK150zyY5bxbSZTv2i5GOdlRTwEM_67xEbSe2CuYpI?feat=directlink .
hi there. the link seems to be broken.
DeleteI'm also having trouble dealing with steering behavior. I'm using Peter newton's one as well.
Will this setup work for physics based pawns, (pawn that moves by the help of "addforceatlocation" and "addforce"..)?
ReplyDeleteYour vehicle AI blog posts are extremely helpful. I do have one question; How do you find out what the max wheel turn angle is for your Vehicle Movement Component? All I know is that the max steering angle changes depending on speed.
ReplyDeleteHi! I'm also trying to do AI vehicles. I'm encountering a problem with NavMesh.
ReplyDeleteHow did you manage to get a route points with offset from walls?
You have used NaveMesh modifieres or sometheng?
This comment has been removed by the author.
ReplyDeleteHey, you can show us how you have done the blueprints?
ReplyDeleteI think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing. Import car from Australia to the UK
ReplyDeleteI guess I am the only one who came here to share my very own experience. Guess what!? I am using my laptop for almost the past 6 years, but I had no idea of solving some basic issues. I do not know how to Download Cracked Pro Softwares But thankfully, I recently visited a website named PCexe.org
ReplyDeleteAll Pro Cracked Softwares Download
Adobe Captivate Crack
Unreal Commander Crack
DiskTrix UltimateDefrag Crack
FastStone Image Viewer Crack
ImBatch Commercial Crack