3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: A mouse driven AI car  (Read 1294 times)

jestermon

« on: September 09, 2010, 03:53:35 PM »
It has always bothered me that the steering mechanism for a car through  script control with the -1, 0, 1 options do not allow for fine steering.

The fact that the car steers perfectly with the keyboard, and also follows a path with very smooth steering, often had me thinking on this paradox.

After playing with the pathfinder and carAI, which uses a target to move the car, the obvious struck me. The key to controlling a car through script - is to use a target which is controlled by a script - and then leave the steering to the car itself.

Here is a little project which does just that. You can steer an AICar with a mouse. This demos serves to show that it is easy to implement a network, keyboard, mouse, joystick, text-file, dll,  or whatever controller you wish, by means of a script

I have used the top-speed factor to provide a�Power� to the car, which can be controlled by the mouse wheel. There are many ways to control the car acceleration from script, but I opted for a simple solution in this demo.

The angle of the target in relation to the direction of the car is controlled through the location of the mouse on the screen.. To the left, and to the right of the center of the screen, control the direction of rotation of the target around the car.

Enjoy.
« Last Edit: September 09, 2010, 03:55:27 PM by jestermon »

PsychoWeasel9

« Reply #1 on: September 09, 2010, 03:57:43 PM »
Brilliant! :o
Now that you mention it, that makes perfect sense, though :)
« Reply #2 on: September 09, 2010, 05:13:07 PM »
It has always bothered me that the steering mechanism for a car through  script control with the -1, 0, 1 options do not allow for fine steering.

what are you talking about? :P

that OUT_xx (which thanks God, still works...) is a float value!
0.01 progressions give you a pretty fine steering.

there you have your fine mouse steering script:
Code: [Select]
void Main()
{
   OUT_0 = (iMouseX()*30.0-15.0)* (-0.1);
}
« Last Edit: September 09, 2010, 05:18:08 PM by loop »
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #3 on: September 09, 2010, 07:51:58 PM »
Interesting Thank you!
but I dont use mouse. I use a digitizer tablet without wheel scroll.

jestermon

« Reply #4 on: September 09, 2010, 08:21:13 PM »
what are you talking about? :P
...OUT_0 = (iMouseX()*30.0-15.0)* (-0.1);

Ahh, yes, true.
« Last Edit: September 09, 2010, 08:29:20 PM by jestermon »
Pages: [1]