Vehicle Acceleration
by James Laker (BurNinG) · in Torque Game Engine · 11/08/2007 (5:56 am) · 4 replies
Hey there.
I'm not quite sure if this has been covered, but Im not 100% sure how to phrase it when searching for it. Let me explain. When I press accelerate, my ship goes faster, until I release the button. When I release the button, my vehicle/ship decelerates.
What would be the best way of implementing a Ship type acceleration. When you press Accelerate you start accelerating faster. Then when you let go of the button the ship/vehicle will continue at that speed/velocity until you press the brake/decelerate button.
I've looked around in the client script, but I'm not sure if this is the correct place to look.
At the moment I have a very bad hack in default.bind.cs:
Can one assume that working with movementSpeed is safe? I dont see how this client variable would be safe to use.
Can anyone give me some input on the subject. I would be greatly appreaciated.
James
I'm not quite sure if this has been covered, but Im not 100% sure how to phrase it when searching for it. Let me explain. When I press accelerate, my ship goes faster, until I release the button. When I release the button, my vehicle/ship decelerates.
What would be the best way of implementing a Ship type acceleration. When you press Accelerate you start accelerating faster. Then when you let go of the button the ship/vehicle will continue at that speed/velocity until you press the brake/decelerate button.
I've looked around in the client script, but I'm not sure if this is the correct place to look.
At the moment I have a very bad hack in default.bind.cs:
function accelerate(%val)
{
if (%val)
{
$mvForwardAction = %val * $movementSpeed;
brake(2);
}
else if (%val == 2)
{
$mvForwardAction = 0;
}
}
function brake(%val)
{
if (%val)
{
$mvBackwardAction = %val * $movementSpeed;
accelerate(2);
}
else if (%val == 2)
{
$mvBackwardAction = 0;
}
}Can one assume that working with movementSpeed is safe? I dont see how this client variable would be safe to use.
Can anyone give me some input on the subject. I would be greatly appreaciated.
James
#2
11/12/2007 (9:30 am)
No... Drag is not really what I'm looking for. When I Dont press FWD, I dont want the ship to slow down. Drag does this. I am talking Spaceship here. Space = No Drag.
#3
11/12/2007 (9:46 am)
Yeah, i was saying try decreasing the Drag to 0 so that you have no drag.
#4
#. .rotationalDrag for flyingVehicle
#. .dragForce / .gyroDrag for hoverVehicle
parameters. You can try setting one/all/needed parameters to zero and see what happens (I would recommend you first to look at the engine sources to be sure that values are accepted by engine and if needed - alter the behaviour if needed).
Also, it's better to do .dump(); on your datablock to see what parameters are accesible and which of those could be helpful for solving your problem...
But if really - I believe there is a time-defendant slow-down by engine and you will need to alter the behaviour in engine anyway. Try to find how you can alter the inertia of the object and if needed - remove all "stopping" mechanisms.
If you will have a look at this from a physics point - drag is not a real point here. Inertia is a power here.
Good luck :)
edit: some corrections of [ b ] codes and... P.S. Sorry for "bad" English, Russian here :)
11/12/2007 (2:21 pm)
If I recall correctly, in your vehicle datablock there are a .drag (ShapeBase-derived), .minDrag, .maxDrag (vehicle-derived) and there are:#. .rotationalDrag for flyingVehicle
#. .dragForce / .gyroDrag for hoverVehicle
parameters. You can try setting one/all/needed parameters to zero and see what happens (I would recommend you first to look at the engine sources to be sure that values are accepted by engine and if needed - alter the behaviour if needed).
Also, it's better to do .dump(); on your datablock to see what parameters are accesible and which of those could be helpful for solving your problem...
But if really - I believe there is a time-defendant slow-down by engine and you will need to alter the behaviour in engine anyway. Try to find how you can alter the inertia of the object and if needed - remove all "stopping" mechanisms.
If you will have a look at this from a physics point - drag is not a real point here. Inertia is a power here.
Good luck :)
edit: some corrections of [ b ] codes and... P.S. Sorry for "bad" English, Russian here :)
Torque Owner Nick Matthews