Vehicle stuff
by Richard Jones · in Torque Game Engine · 03/26/2002 (4:05 pm) · 19 replies
Hi,
(1) Does anyone know how to reduce the sensitivity of the steering for wheeled vehicles? At the moment they are too difficult to control because you only need to move your mouse slightly and you'll get full steering lock.
(2) I've tried to add sound effects to my vehicle, but I don't hear anything. Am I doing something wrong or is this not implemented in the engine? I tried to assign the footfall sound as the engine sound to see if it would play when I drove the car, but it it didn't work.
(1) Does anyone know how to reduce the sensitivity of the steering for wheeled vehicles? At the moment they are too difficult to control because you only need to move your mouse slightly and you'll get full steering lock.
(2) I've tried to add sound effects to my vehicle, but I don't hear anything. Am I doing something wrong or is this not implemented in the engine? I tried to assign the footfall sound as the engine sound to see if it would play when I drove the car, but it it didn't work.
About the author
#2
03/27/2002 (12:20 am)
For the sound, be sure to have the latest release, as if I remember correctly, there was a bug in the previous release of the vehicle code.
#3
SteeringForce didn't seem to make a difference :( I tried really low values and really high values but I still only need to move the mouse a fraction to get full steering lock.
@Frank - do you mean I should get the latest head release? I've got a head release from a few weeks back, was it broken then? Anyway, here's my code for vehicle sounds. If you think that it should work then I'll get the latest head release. :)
In car.cs I have:
datablock AudioProfile(EngineSound)
{
fileName = "~/data/sound/vehicle/engine.wav";
description = AudioDefaultLooping3d;
preload = true;
};
datablock AudioProfile(SkidSound)
{
fileName = "~/data/sound/vehicle/skid.wav";
description = AudioClose3d;
preload = true;
};
Also in car.cs in the WheeledVehicleData(Car) datablock I have:
engineSound = EngineSound;
squealSound = SkidSound;
Have I missed something?
03/27/2002 (5:20 am)
Thanks for your help.SteeringForce didn't seem to make a difference :( I tried really low values and really high values but I still only need to move the mouse a fraction to get full steering lock.
@Frank - do you mean I should get the latest head release? I've got a head release from a few weeks back, was it broken then? Anyway, here's my code for vehicle sounds. If you think that it should work then I'll get the latest head release. :)
In car.cs I have:
datablock AudioProfile(EngineSound)
{
fileName = "~/data/sound/vehicle/engine.wav";
description = AudioDefaultLooping3d;
preload = true;
};
datablock AudioProfile(SkidSound)
{
fileName = "~/data/sound/vehicle/skid.wav";
description = AudioClose3d;
preload = true;
};
Also in car.cs in the WheeledVehicleData(Car) datablock I have:
engineSound = EngineSound;
squealSound = SkidSound;
Have I missed something?
#4
maxSteeringAngle is the variable you are interested in. The larger the value, the more mouse movement is needed for a given amount of steering lock. Go with a value of 10 to 15 and you should get a good grasp on the effect.
03/27/2002 (6:51 am)
Richard,maxSteeringAngle is the variable you are interested in. The larger the value, the more mouse movement is needed for a given amount of steering lock. Go with a value of 10 to 15 and you should get a good grasp on the effect.
#5
If this is working for everyone else, maybe I should get the latest head release to see if it makes any difference.
Also, I wonder how difficult it would be to change the controls so you could steer the vehicle using keyboard or joystick (rather than the analogue mouse control)? So for example, pressing a key to turn right would increase the steering angle as long as it was pressed and as soon as the key was depressed the steering wheel would spring back to the centre.
03/27/2002 (7:16 am)
It doesn't work. The difference between turning full lock left and full lock right only seems to be about 1cm on the mousemat, regardless of the maxsteeringangle value (I've tried 1, 12 & 1000). This is way too sensitive, so I tend to swerve all over the place constantly trying to keep the vehicle going in a straight line by moving the mouse a few millimetres left and right. This makes it very difficult to stay on the right side of the road!If this is working for everyone else, maybe I should get the latest head release to see if it makes any difference.
Also, I wonder how difficult it would be to change the controls so you could steer the vehicle using keyboard or joystick (rather than the analogue mouse control)? So for example, pressing a key to turn right would increase the steering angle as long as it was pressed and as soon as the key was depressed the steering wheel would spring back to the centre.
#6
I know I made an if statement that checked for move->pitch and if not it would set mSteering.x & .y to 0.
I'll post the actual code when I get home, but it's not perfect, there needs to be a countdown of some sort so the wheels don't just magically snap back, but it's a lot easier to drive around then before.
Also to use the keyboard just bind keys to look left and right. Sorry for the partial answer, but I'll have more to tell later.
03/27/2002 (11:37 am)
I made a hack to vehicle.cc that does just that, I'm at work at the moment and don't have the changes in front of me but the bit of code you want to look at is:// Steering
if (move != &NullMove)
{
F32 y = move->yaw;
mSteering.x = mClampF(mSteering.x + y,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
F32 p = move->pitch;
mSteering.y = mClampF(mSteering.y + p,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
}
else
{
mSteering.x = 0;
mSteering.y = 0;
}I know I made an if statement that checked for move->pitch and if not it would set mSteering.x & .y to 0.
I'll post the actual code when I get home, but it's not perfect, there needs to be a countdown of some sort so the wheels don't just magically snap back, but it's a lot easier to drive around then before.
Also to use the keyboard just bind keys to look left and right. Sorry for the partial answer, but I'll have more to tell later.
#7
03/27/2002 (1:03 pm)
Thanks for that. I'll have a look at it.
#8
Like I said, it's a quick hack but it works...
03/27/2002 (7:52 pm)
Here's the change I made, I was wrong it was the move->yaw I was checking not the pitch:// Steering
if (move != &NullMove)
{
if(move->yaw ){
F32 y = move->yaw;
mSteering.x = mClampF(mSteering.x + y,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
F32 p = move->pitch;
mSteering.y = mClampF(mSteering.y + p,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
}
else
{
mSteering.x = 0;
mSteering.y = 0;
}
}
else
{
mSteering.x = 0;
mSteering.y = 0;
}Like I said, it's a quick hack but it works...
#9
On another matter, does your vehicle brake OK? I've tried to make the brakes more responsive, but increasing the brakeTorque value doesn't seem to make a difference. I assume its the key bind "Backwards" that is the actual brake (which is 'S' by default)? I've managed to increase the engineBrake value, which slows down the car much quicker when you are not accelerating, but I can't seem to adjust the brakes. Any tips?
I've downloaded the latest head release and I still don't get any vehicle sounds although other sounds do work. My vehicle sound code is posted above, is the syntax correct?
Thanks
03/28/2002 (7:55 am)
Thanks Kevin for your code.On another matter, does your vehicle brake OK? I've tried to make the brakes more responsive, but increasing the brakeTorque value doesn't seem to make a difference. I assume its the key bind "Backwards" that is the actual brake (which is 'S' by default)? I've managed to increase the engineBrake value, which slows down the car much quicker when you are not accelerating, but I can't seem to adjust the brakes. Any tips?
I've downloaded the latest head release and I still don't get any vehicle sounds although other sounds do work. My vehicle sound code is posted above, is the syntax correct?
Thanks
#10
As for the sounds. I had these datablocks while testing and they worked fine.
datablock AudioProfile(CarSqueelSound)
{
filename = "~/Data/Sounds/squeal.wav";
description = AudioDefaultLooping3d;
preload = true;
};
datablock AudioProfile(CarEngineSound)
{
filename = "~/data/sounds/Engine.wav";
description = AudioDefaultLooping3d;
preload = true;
};
engineSound = CarEngineSound;
squealSound = CarSqueelSound;
Maybe try Naming them something other then the name of the datablock member.. I'm not sure why they wouldnt work
besides a wrong path?
03/28/2002 (7:59 am)
The spacebar is the actual brakes.As for the sounds. I had these datablocks while testing and they worked fine.
datablock AudioProfile(CarSqueelSound)
{
filename = "~/Data/Sounds/squeal.wav";
description = AudioDefaultLooping3d;
preload = true;
};
datablock AudioProfile(CarEngineSound)
{
filename = "~/data/sounds/Engine.wav";
description = AudioDefaultLooping3d;
preload = true;
};
engineSound = CarEngineSound;
squealSound = CarSqueelSound;
Maybe try Naming them something other then the name of the datablock member.. I'm not sure why they wouldnt work
besides a wrong path?
#11
As I say, I have the S key mapped to "Backwards" and this will reverse the car if it is not moving, and I assume it should act as the brake if you are travelling forwards, but it just doesn't seem to slow the car down very well. As a result, I can't slow down for my T-junctions, very dangerous! Good job there's no AI cars yet!
03/28/2002 (8:16 am)
I have the spacebar mapped to "jump" which exits the vehicle. I remapped "jump" to something else and the spacebar didn't slow down the car.As I say, I have the S key mapped to "Backwards" and this will reverse the car if it is not moving, and I assume it should act as the brake if you are travelling forwards, but it just doesn't seem to slow the car down very well. As a result, I can't slow down for my T-junctions, very dangerous! Good job there's no AI cars yet!
#12
This is from a changelog:
"Breaks are now activated by trigger[2] (the jump key)."
So try using whatever key is bound to trigger[2]and remapping the exit vehicle.
And if you want to change it off of trigger[2] go to wheeledVehicle.cc and search for this and replace it with what you want to use.
void WheeledVehicle::updateMove(const Move* move)
{
Parent::updateMove(move);
// Break on trigger
mBraking = move->trigger[2];<---
03/28/2002 (8:26 am)
Going in reverse will slow you down but will not apply the brakesThis is from a changelog:
"Breaks are now activated by trigger[2] (the jump key)."
So try using whatever key is bound to trigger[2]and remapping the exit vehicle.
And if you want to change it off of trigger[2] go to wheeledVehicle.cc and search for this and replace it with what you want to use.
void WheeledVehicle::updateMove(const Move* move)
{
Parent::updateMove(move);
// Break on trigger
mBraking = move->trigger[2];<---
#13
I did a search for trigger[2] in the engine code and noticed the following:
if(move->trigger[2] && isMounted())
Con::executef(mDataBlock,2,"doDismount",scriptThis());
So obviously, when I press the spacebar, I exit the vehicle instead of slowing down because this is also mapped to trigger[2]. Therefore, to solve the problem I need to assign a different trigger to the dismount, and this is where I'm a bit stuck. How would I edit the above code so that the dismount is activated by, for example, the "E" key? At the moment I don't understand where the link is between triggers and actual keys. Where is the engine told trigger[2] is the key assigned to the jump function?
Thanks in advance.
03/28/2002 (9:52 am)
I've just tried using the "jump" key (space bar) in the racing demo and this does work the brakes. However, in my project you don't control the vehicle directly, you control a character that can enter and exit vehicles.I did a search for trigger[2] in the engine code and noticed the following:
if(move->trigger[2] && isMounted())
Con::executef(mDataBlock,2,"doDismount",scriptThis());
So obviously, when I press the spacebar, I exit the vehicle instead of slowing down because this is also mapped to trigger[2]. Therefore, to solve the problem I need to assign a different trigger to the dismount, and this is where I'm a bit stuck. How would I edit the above code so that the dismount is activated by, for example, the "E" key? At the moment I don't understand where the link is between triggers and actual keys. Where is the engine told trigger[2] is the key assigned to the jump function?
Thanks in advance.
#14
in player.cs change:
then recompile.
Now in the scripts after the jump function in default.bind.cs make this new function:
Now it is hard coded, but it's nicer to have it listed in the options menu so in optionsDig.cs you need to add this:
Now it should show up in the control options. I think that was all I had to do, let me know if it works for you.
03/28/2002 (2:34 pm)
Ok, I really don't know too much C++, but I needed to do this as well, I don't know if this is the easiest or most practical way to do this but it works. A few different files need to be edited, on the engine side just player.cc, and on the script side default.bind.cs, and optionsDig.cs in player.cs change:
if (isMounted()) {
// Filter Jump trigger if mounted
pMove.trigger[2] = move->trigger[2];
cMove.trigger[2] = false;
}toif (isMounted()) {
// Filter Jump trigger if mounted
pMove.trigger[4] = move->trigger[4];
cMove.trigger[4] = false;
}then change under if (!isGhost()) {}if(move->trigger[2] && isMounted())
Con::executef(mDataBlock,2,"doDismount",scriptThis());toif(move->trigger[4] && isMounted())
Con::executef(mDataBlock,2,"doDismount",scriptThis());then recompile.
Now in the scripts after the jump function in default.bind.cs make this new function:
function getOut(%val)
{
$mvTriggerCount4++;
}Then add this below that with the rest of the moveMap.bin()'smoveMap.bind( keyboard, e, getOut );
Now it is hard coded, but it's nicer to have it listed in the options menu so in optionsDig.cs you need to add this:
$RemapName[$RemapCount] = "Exit Vehicles"; $RemapCmd[$RemapCount] = "getOut"; $RemapCount++;with the rest of the $RemapCount++'s
Now it should show up in the control options. I think that was all I had to do, let me know if it works for you.
#15
Have you implemented vehicle sounds? Its obviously not a big issue at the moment, but its just frustrating me that I can't get it to work and I have no idea why. As a developer I always find it amazing how adding sound effects brings a project to life and turns it from an app into a game!
Anyway I'm starting to waffle, thanks again.
03/29/2002 (3:52 pm)
@Kevin - I got it working. Thanks for the code and the really clear instructions as well, I appreciate it. :)Have you implemented vehicle sounds? Its obviously not a big issue at the moment, but its just frustrating me that I can't get it to work and I have no idea why. As a developer I always find it amazing how adding sound effects brings a project to life and turns it from an app into a game!
Anyway I'm starting to waffle, thanks again.
#16
03/30/2002 (2:38 am)
No, I haven't even began to mess around the sound or sfx at all, but I'll get there eventually... One step at a time :)
#17
http://www.garagegames.com/mg/snapshot/view.php?qid=83
It looks like he has all the sounds working, so it is possible :)
03/30/2002 (3:17 am)
ok, so I decided to play around with the sounds for a bit and I got softImpactSound & hardImpactSound to work with no problem... I couldn't get engineSound or squealSound or any others to work though... I didn't really get into it that much though. I just assigned the footfall sound for all of the commented sound settings and narrowed it down to only those two working. Not sure why the engine sound doesn't. I remembered seeing this screen shot from the other day:http://www.garagegames.com/mg/snapshot/view.php?qid=83
It looks like he has all the sounds working, so it is possible :)
#18
In wheeledVehicle.cc:
Change the bold text in this function:
to
Then in your vehicleDriverMap.cs (or whatever file you use) :
Works like a charm - thanks for the help 'yall!
Now I've got to figure out how to "lock the brakes" so the player can do slide-outs .... any ideas?
09/19/2007 (10:04 am)
A slightly easier solution to the brakes problem: (described by Bruce Wallace above)In wheeledVehicle.cc:
Change the bold text in this function:
void WheeledVehicle::updateMove(const Move* move)
{
Parent::updateMove(move);
// Break on trigger
[b]mBraking = move->trigger[2];[/b]to
// Break on trigger [b]mBraking = move->trigger[4];[/b] // I'm unsure why not to use 3???
Then in your vehicleDriverMap.cs (or whatever file you use) :
function handbrake(%val)
{
$mvTriggerCount4++;
}Works like a charm - thanks for the help 'yall!
Now I've got to figure out how to "lock the brakes" so the player can do slide-outs .... any ideas?
#19
P.S. Trigger 3 is reserved for jetting/boost, that's why I use trigger 4. Jetting on the player (if you've implemented the code) and turbo/boost for all vehicle classes.
09/19/2007 (10:22 am)
Yeah, I do that too. Was never sure why trigger 2 was used for the handbrake when it is also assigned to the player jump action. Fine when the vehicle is the control object but when you're mounting a player to a vehicle it causes a conflict. P.S. Trigger 3 is reserved for jetting/boost, that's why I use trigger 4. Jetting on the player (if you've implemented the code) and turbo/boost for all vehicle classes.
Torque Owner Adam