Hi everybody, I've been attempting to make some scenarios against the AI, and because I'm a total beginner, I need to ask some questions. So basically, I want to make a drag race, preferably on a mesh road. Using the LUA of the official 'Airfield Showdown', I have the issue of the AI attempting to drive left (and then right, after they hit a wall) at the very start. I did place the waypoints perfectly up ahead on a straight, completely even road. Either way, all I need to code is to make the AI hold the pedal and adjust to certain x and y coordinates. I've been trying a lot with replacing and coding it myself (using dragAI), but it never worked. I'd be very happy to have someone help me out. This would also enable me to code some oval racing, hopefully. Thanks in advance!
You say that, but I don't see a single question in your post. This is how you should be doing it, so show us what you did. It works in Airfield Showdown, so you're probably just doing it wrong. What did you try? What did you expect it to do? What did it do instead? There are plenty of guides on how to ask questions about coding (like here or here) if you need help.
Thank you for your response! You are, of course, right. I should have included more information in my post. I tried to make the scenario on GridMap: Copying all the contents and translating all vehicles plus checkpoints did make for a working scenario. However, upon rotating all those, the AI steers towards what I believe to be the original orientation of the waypoint set as a target (clearing cache did not help). I did make sure - multiple times - that waypoints are placed correctly. So the question is; how do I make it target the waypoint correctly? I can show you my files, but the only important thing I changed is the positions/rotations of those in the prefab. I simply edited the picture, edited the html and added a line specifying the .prefab in the .json, yet it never worked with or without those changes... But to make it easier for you, here's the file:
Thank you for the extra information, and, more importantly: the example! Having something to test with makes things a lot easier. Anyway, long story short, you've found a bug in the game! Your code is fine, the drag AI simply contains a mistake that makes it not work if the drag race isn't aligned with the Y-axis. That's why the vehicle turns: it's trying to align itself with that axis. I've reported the bug, so it'll probably be fixed next update. Controlling the AI manually is doable, but annoying, so unless you can't (in which case: feel free to ask more questions), I'd recommend waiting for a fix.
Thanks, that really cleared up the issue here! Also, I realised that the AI isn't hardcoded. If the issue lies within the mathematic expression of the dragAi.lua, I shouldn't have many problems getting it to work.
Thanks for the heads up, I've read the changelogs (and the typos, lol). I'd try again, but I'm going on holidays today.