1 registered members (AndrewAMD),
1,244
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: [newton]about accleration
[Re: HackerL]
#97024
11/01/06 23:27
11/01/06 23:27
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
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; }
|
|
|
Re: [newton]about accleration
[Re: HackerL]
#97026
11/02/06 20:24
11/02/06 20:24
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
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++.
|
|
|
Re: [newton]about accleration
[Re: HackerL]
#97028
11/02/06 22:04
11/02/06 22:04
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
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.
Last edited by testDummy; 11/02/06 22:07.
|
|
|
Re: [newton]about accleration
[Re: testDummy]
#97029
11/02/06 22:16
11/02/06 22:16
|
Joined: Aug 2005
Posts: 176 Latvia
HackerL
OP
Member
|
OP
Member
Joined: Aug 2005
Posts: 176
Latvia
|
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
|
|
|
|