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: simple but effective PCar angular damping Script  (Read 297 times)

« on: March 15, 2014, 03:13:12 PM »
Here is a small simple script I put together that dampens the PCars physics the faster it goes.
Code: [Select]
void Main()
{
///////////////////////////////////////////////////////////////////////////////////////////////////////
//Simple pcar angular damping script By Dogtorque
///////////////////////////////////////////////////////////////////////////////////////////////////////
float X = 0;
float Y = 0;
float Z = 0;
X += IN_0*0.001;
Y += IN_0*0.001;
Z += IN_0*0.001;
iObjectDampingApply(OBJ_0,X,Y,Z,true,false);
///////////////////////////////////////////////////////////////////////////////////////////////////////
}
« Last Edit: March 16, 2014, 12:13:09 PM by dogtorque »
I be trippin!
« Reply #1 on: March 16, 2014, 02:39:29 PM »

If you look into your code you see that X Y and Z are always the same ... so you just need X ... delete the 4 lines starting with float Y, float Z, Y +=, Z += ... and replace Y and Z with X in iObjectDampingApply( ... )
You do not have to calculate the same result 3 times each frame ...

Using 3D Rad 7.22
« Reply #2 on: March 17, 2014, 05:50:35 AM »

If you look into your code you see that X Y and Z are always the same ... so you just need X ... delete the 4 lines starting with float Y, float Z, Y +=, Z += ... and replace Y and Z with X in iObjectDampingApply( ... )
You do not have to calculate the same result 3 times each frame ...
no the X Y Z axis are affecting different orientation axis. if you check out the script object reference page it says...

iObjectDampingApply(OBJ_X,float,float,float,bool,bool)
   Apply damping factors individually to each axis of the specified rigid-body-based object (RigidBody, Car, PCar etc).
   OBJ_X = object handle
   float,float,float = damping factors for X, Y and Z axes.
                       Recommended damping values are between 0.0 (no damping) and 1.0 (maximum damping).
   bool = set this parameter to 'true' to apply the damping factor to object's rotation.
          Set it to false to apply the damping factors to object's translation.
   bool = set this parameter to 'true' to use object's local axes as reference.
          Set it to false to use world space axes as reference.
   NOTE: this function must be called at every script loop in order to work properly.

so I need X,Y,and Z in there.
I be trippin!
« Reply #3 on: March 17, 2014, 07:56:36 AM »
My god.

I think he is serious.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #4 on: March 17, 2014, 10:46:30 AM »

It's not a matter of what the Damping Function does ... its what your code does ... since you in each line multipliy IN_0 by 0.001 you will have 3 times the same result ... so you do not need to do it 3 times!
Dog ... next time think first, then prove me wrong if you can ... but do not write such a rubbish as you did in your posts :D


.
« Last Edit: March 17, 2014, 10:54:47 AM by Leonopteryx »
Using 3D Rad 7.22
« Reply #5 on: March 17, 2014, 02:34:44 PM »

It's not a matter of what the Damping Function does ... its what your code does ... since you in each line multipliy IN_0 by 0.001 you will have 3 times the same result ... so you do not need to do it 3 times!
Dog ... next time think first, then prove me wrong if you can ... but do not write such a rubbish as you did in your posts :D


.
hey! I'm learning  okay! this is the first script I wrote from scratch!
« Last Edit: March 17, 2014, 02:38:05 PM by dogtorque »
I be trippin!
« Reply #6 on: March 17, 2014, 02:36:33 PM »
I be trippin!
« Reply #7 on: March 17, 2014, 04:39:46 PM »

It's not a matter of what the Damping Function does ... its what your code does ... since you in each line multipliy IN_0 by 0.001 you will have 3 times the same result ... so you do not need to do it 3 times!
Dog ... next time think first, then prove me wrong if you can ... but do not write such a rubbish as you did in your posts :D


.
hey! I'm learning  okay! this is the first script I wrote from scratch!

It looked like that ... that's why I answered your first post and explained what you should watch in your code.

If you use different values (i.e. 0.001 0.035 0.002) for each multiplication or if the IN values are different then your code is ok. Then you need 3 multiplications. But since you don't, its a waste of calculation time ... not very important in such a small code ... but in longer code it sums up and you always try to write the quickest code as possible.
That was what I wanted to tell you in my answer post ... there was no need, telling how the function is explained in the script reference. We know that and it's obvious.

PS: As you might know me from former posts I actually wanted to write something like: Wow ... this will qualify you for the Physics Nobel Price ... You are the new Einstein of our time ...  ;D  ... but I had a gentle moment ... LOL ... so I only explained what you could optimize in your code ...
.
« Last Edit: March 17, 2014, 04:49:55 PM by Leonopteryx »
Using 3D Rad 7.22
« Reply #8 on: March 22, 2014, 05:13:37 PM »

It's not a matter of what the Damping Function does ... its what your code does ... since you in each line multipliy IN_0 by 0.001 you will have 3 times the same result ... so you do not need to do it 3 times!
Dog ... next time think first, then prove me wrong if you can ... but do not write such a rubbish as you did in your posts :D


.
hey! I'm learning  okay! this is the first script I wrote from scratch!

It looked like that ... that's why I answered your first post and explained what you should watch in your code.

If you use different values (i.e. 0.001 0.035 0.002) for each multiplication or if the IN values are different then your code is ok. Then you need 3 multiplications. But since you don't, its a waste of calculation time ... not very important in such a small code ... but in longer code it sums up and you always try to write the quickest code as possible.
That was what I wanted to tell you in my answer post ... there was no need, telling how the function is explained in the script reference. We know that and it's obvious.

PS: As you might know me from former posts I actually wanted to write something like: Wow ... this will qualify you for the Physics Nobel Price ... You are the new Einstein of our time ...  ;D  ... but I had a gentle moment ... LOL ... so I only explained what you could optimize in your code ...
.
thank you...and at least I tried. :)
I be trippin!
Pages: [1]