AI that can mount and drive vehicles?
by Ron Nelson · in Torque Game Engine · 08/23/2007 (1:14 am) · 13 replies
I wanted to see if there was a resource or code available that already can do this. BAsically I want my AI Bots to be able to mount and drive vehicles. I have been working at this already quite a bit with only bots that dirve in circles or don't obey commands at all.
Anyone?
Anyone?
#2
However, if you look at the video I made you can see there is something odd about how it steers. YEs it gets around just fine, but the constant turning to max steering angle all of the time is rather odd.

HAs anyone got an idea how to stop this?
08/24/2007 (10:51 am)
Well I successfully managed to make a AI driver that can mount and drive vehicles with a mixture of code from the aiWheeledVehicle code and a heavily modified version of the AIPatrol Resource.However, if you look at the video I made you can see there is something odd about how it steers. YEs it gets around just fine, but the constant turning to max steering angle all of the time is rather odd.

HAs anyone got an idea how to stop this?
#3
your tolerance perhaps is too small.
you need some more slop.
I wrote some code here in the forums that does just this.
has the AI mount the vehicle and the AI is steering it.
you should be able to still find it, people have modified it and made resources and stuff out of it.
its all here, just poke around some more.
Edit:
Here is the original thread:
www.garagegames.com/mg/forums/result.thread.php?qt=5091
from there you should be able to find linkage to the added work people have done.
08/24/2007 (12:22 pm)
Tolerance.your tolerance perhaps is too small.
you need some more slop.
I wrote some code here in the forums that does just this.
has the AI mount the vehicle and the AI is steering it.
you should be able to still find it, people have modified it and made resources and stuff out of it.
its all here, just poke around some more.
Edit:
Here is the original thread:
www.garagegames.com/mg/forums/result.thread.php?qt=5091
from there you should be able to find linkage to the added work people have done.
#4
08/24/2007 (7:09 pm)
Maybe you should give him a DUI test.
#5
@Badguy - Yes I have seen your work and it has been guidance for a lot of my own. However, adjusting the tolerance made no difference. But I think I found another symptom. If I dismount the AI player, he is the one doing circles now.
Something is obviously wrong. Well all of my other functions are identical to those contained in aiWheeledVehicle and aiPatrol with only the names changed to AIDriver. This is the only function that is different. Yes I want the player to be able to shoot weapons mounted on the car too. Thats why the aim functions are there too.
***Code removed. See lower post***
08/24/2007 (10:37 pm)
@Steve - LOL@Badguy - Yes I have seen your work and it has been guidance for a lot of my own. However, adjusting the tolerance made no difference. But I think I found another symptom. If I dismount the AI player, he is the one doing circles now.
Something is obviously wrong. Well all of my other functions are identical to those contained in aiWheeledVehicle and aiPatrol with only the names changed to AIDriver. This is the only function that is different. Yes I want the player to be able to shoot weapons mounted on the car too. Thats why the aim functions are there too.
***Code removed. See lower post***
#6
I created a standard aiWheeledVehicle and made it mountable. It drove just fine.
Then I mounted it, the AI is still in control. It still drives fine though. So it obviously has nothing to do with mounting or my modified vehicle code, it must be my AIDriver code.
However, I really don't want the vehicle to be ai controlled all of the time so this is really not a working option for me.
Which brings me back to the need to determine the control object being a vehicle or player in getAIMove.
08/25/2007 (4:36 pm)
OK, it has to be my code. I created a standard aiWheeledVehicle and made it mountable. It drove just fine.
Then I mounted it, the AI is still in control. It still drives fine though. So it obviously has nothing to do with mounting or my modified vehicle code, it must be my AIDriver code.
However, I really don't want the vehicle to be ai controlled all of the time so this is really not a working option for me.
Which brings me back to the need to determine the control object being a vehicle or player in getAIMove.
#7
HAs someone developed something better that does what I am looking for?
08/25/2007 (5:40 pm)
OK with everything I have tested so far, I can see that the problem seems to lie in the fact that I am using my code as a player class and that somehow it interferes with the steering operation since as far as I can tell it is trying to tell the car to take foot steps and this is why I am getting the left right repeated turn issue. HAs someone developed something better that does what I am looking for?
#8
I still haven't gotten around the issue with it having the driving issue above or when you tell the bot to dismount he just sits there and spins. I am positive the script is set properly, so it must be the code.
I have even done tests to check in code if the isMounted() is working now, it is.
I am putting my code up for a bit in hopes someone can tell me what is wrong with it. I suspect it has to do with the way the player is moved interfering with the vehicle, but that confuses me about the player spinning issue.
Download aiDriver.h
Download aiDriver.cc
Feel free to use this, but as a condition, if you fix it, I want the fix.
Or if someone is just feeling really generous, I would appreciate some help.
Thanks in advance
08/26/2007 (1:40 am)
Ok I managed to come up with a solution to the detecting whether the bot was in a car or not by making a function that is called during mount and dismounts for the bot to adjust a variable that is used to determine this.I still haven't gotten around the issue with it having the driving issue above or when you tell the bot to dismount he just sits there and spins. I am positive the script is set properly, so it must be the code.
I have even done tests to check in code if the isMounted() is working now, it is.
I am putting my code up for a bit in hopes someone can tell me what is wrong with it. I suspect it has to do with the way the player is moved interfering with the vehicle, but that confuses me about the player spinning issue.
Download aiDriver.h
Download aiDriver.cc
Feel free to use this, but as a condition, if you fix it, I want the fix.
Or if someone is just feeling really generous, I would appreciate some help.
Thanks in advance
#9
08/26/2007 (7:25 pm)
OK I will ask a diffrent questiuon, which may allow me to solve this on my own. How does the engien switch controls for a human player from the player class to wheeledvehicle class when the human player mounts a vehicle?
#10
08/26/2007 (10:50 pm)
Well never mind all of the above dealing with the player dismounting issues. I used the Flight Compendium resource and it cured that issue. I have tried to do several different things for the steering issue with no success however.
#11
08/27/2007 (10:29 am)
Wel as it turns out one of the posts made at the site by Ehab was a fix. Thanks all.
#12
The reason is using James Jacoby's steering code with Ehab's adjustment really makes the player's steering return too fast now. It works great for the bots though.
This is what I have so far for a preliminary test, it doesn't work right just yet because I need to determine the driver and then his connection but I am a bit foggy on how to do that.
Thanks in advance for any help you can give me.
08/27/2007 (10:49 am)
Because of Ehab's fix I need to setup a check in the Wheeled Vehicle's updateMove code to determine wheter or not the vehicle is being driven by a bot.The reason is using James Jacoby's steering code with Ehab's adjustment really makes the player's steering return too fast now. It works great for the bots though.
This is what I have so far for a preliminary test, it doesn't work right just yet because I need to determine the driver and then his connection but I am a bit foggy on how to do that.
GameConnection* conn = GameConnection::getConnectionToServer(); if(conn->isAIControlled()) Con::errorf(ConsoleLogEntry::General, "Is AI Controlled Test 1"); if(!conn->isAIControlled()) Con::errorf(ConsoleLogEntry::General, "Is AI Controlled Test 2");
Thanks in advance for any help you can give me.
#13
but this is problem for me because i don't want bot to mount vehicle..
this because is not assigned "command by press e for example" but is on collision mount.. ..
11/02/2009 (8:20 pm)
Sorry but in my testing the ai mount vehicle is vehicle is in path zone in automatic mode without any changing of the engine code:)but this is problem for me because i don't want bot to mount vehicle..
this because is not assigned "command by press e for example" but is on collision mount.. ..
Torque Owner Henry Todd
Placeholder
Because the vehicle itself does the navigation in this case, you don't actually need to mount an aiPlayer to it. However, if you want a driver to be visible, and the vehicle to actually carry an aiPlayer who later gets out, that can be done (as it's a Vehicle, you can still mount Players to the ai Vehicles). If you're using it like this, you'll probably want to include some logic to prevent the vehicle from moving when it doesn't have a driver.