[newton]about accleration

Posted By: HackerL

[newton]about accleration - 11/01/06 18:56

Ok, i have tried to get that my car wount stop, when i release my accleration button. I have made NO progress! I know, i am not too good with c++, i prefer turbo pascal :O!

Code:
 		if(key_cuu)
{
my.carEngineTorque = my.car_maxToque * 1.0;
else
{
my.carEngineTorque = -0.3;
}
}


Posted By: testDummy

Re: [newton]about accleration - 11/01/06 23:27

Code:

my.carEngineTorque = 0;
my.carSteerTorque = 0;
if (key_cul || key_a) {
my.carSteerTorque = 1.0;
}
if (key_cur || key_d) {
my.carSteerTorque = -1.0;
}
if (key_cuu || key_w) {
my.carEngineTorque = my.car_maxTorque; //*1.0 does not modify value
}
if (key_cud || key_s) {
my.carEngineTorque = -my.car_maxTorque * 0.5;
}


Posted By: HackerL

Re: [newton]about accleration - 11/02/06 19:38

it is an tip?
Posted By: testDummy

Re: [newton]about accleration - 11/02/06 20:24

Quote:

it is an tip?



Quoted HackerL.
I can't interpret that.
In Newton, if you use the right script functions that are included for 'Newton cars', and setup 'input' values correctly, acceleration and deacceleration should be handled by Newton nearly automatically. If you press the forward key the car should gradually approach top speed and then remain there while the forward key is pressed. If you release the forward key, the car's speed should gradually decrease.

If you setup everything correctly or if just use the 'default setup', the car shouldn't just immediately stop when no key is pressed.

You probably don't want to set my.carEngineTorque = -0.3 when the forward key isn't pressed because the car will probably eventually start going backwards when the user isn't pressing a key. Essentially, if you just reset my.carEngineTorque to 0, and no key is pressed the car should probably just gradually slow down. For the most part, you probably don't need to 'muck' with acceleration directly.

C-Script is not C++.
Posted By: HackerL

Re: [newton]about accleration - 11/02/06 21:17

So ia have tried some other sing, and yes you are right about the part , when my.carEngineTorque is 0,0, my car is starting to go backwards, can you fix this script!?

Code:
  		// read wheel controls
if(key_cul)
{
my.carSteerTorque = 1.0;
}
if(key_cur)
{
my.carSteerTorque = -1.0;
}
if(key_cuu)
{
my.carEngineTorque = my.car_maxToque;
}
else
{
my.carEngineTorque = -60.0; //the car speed is decreasing
}
if(key_cud)
{
my.carEngineTorque = -my.car_maxToque * 0.5;
}
if(key_shift)
{
my.carEngineTorque = my.car_maxToque * 5.0;
}
wait(1);
}
}


Posted By: testDummy

Re: [newton]about accleration - 11/02/06 22:04

It seems I might have wasted some of my time writing my last post in this thread.
Code:

/*
Notes:
arrow keys left/right to steer
up arrow key to move forward
down arrow key to move backward slower than moving forward
shift + up/down arrow key to move forward/backward faster
*/
//reset the torque values to 0
//torque values will be 0 if no key is pressed
//the car 'coasts' if no key is pressed
my.carEngineTorque = 0;
my.carSteerTorque = 0;
//...
if (key_cul) {
my.carSteerTorque = 1.0;
}
if (key_cur) {
my.carSteerTorque = -1.0;
}
if (key_cuu) {
my.carEngineTorque = my.car_maxToque;
} /* else {
my.carEngineTorque = -60.0; // NO! You don't need to do this.
} */
if (key_cud) {
my.carEngineTorque = -my.car_maxToque * 0.5; //only half-speed in reverse
}
if (key_shift) {
//'turbo' will be applied in reverse or forward, but not otherwise
my.carEngineTorque = my.carEngineTorque * 5;
}
//...
wait(1);


Newton might be considered an 'intermediate topic' for users that might have reached an 'intermediate' skill level.
If you are going to use Newton, you might try to study the 'example' scripts included with Newton thoroughly.
Posted By: HackerL

Re: [newton]about accleration - 11/02/06 22:16

i have settings for newton vehicle orginal, and i hate when i release accleration key, and my car stops immediatly, and when it does, i can't steer any more!

What i wrote, with script i wanted to get -

When accleration button is released, then my current speed decreasing, when my current speed is 0,0 then decreasing process should break or stop! Can you do that, because my c++ skills isnt impresive
Posted By: TheStonerunner

Re: [newton]about accleration - 11/03/06 05:20

I had the same issue with something similar. What you want, rather than setting it to = -0.3 is

whatever you're trying to decrease -= 0.3;

that decreases it a bit at a time. You might also want to factor in some other variables, so that the decrease in speed is more realistic. But that's how you bring it down a bit at a time, rather than all at once.
© 2024 lite-C Forums