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: Suspension Riser/lower script (aka Suspension air bags)  (Read 175 times)

« on: May 02, 2014, 08:00:14 AM »
Code: [Select]
//IN_22 is for the Counter or ValuePrint object
/////////////////////////////////////////////////////////////////////////
///////////////Suspension Air Bag Script/////////////////////////////
/////////////////////////////////////////////////////////////////////////
int MAX_AXLE_TORQUE_FRONT = 100;
int SUSPENSION_TRAVEL_FRONT = 6;
int SUSPENSION_TARGET_FRONT = 7;
//////////////////////////////////////////////////////
int MAX_AXLE_TORQUE_REAR = 100;
int SUSPENSION_TRAVEL_REAR = 106;
int SUSPENSION_TARGET_REAR = 107;
//////////////////////////////////////////////////////
int MAX_CAR_SPEED = 200;
int CENTER_OF_MASS_OFFSET_Y = 205;
////////////////////////////////////////////////////////////////////////
float V4 = 0.02;////the amount time for the supsension travel to lower//
//value the longer it takes for the car to lower it's suspension travel/
//don't know why it works like that.////////////////////////////////////
////////////////////////////////////////////////////////////////////////
float V1 = 1.5f/60f;
float V2 = V4;
float V3 = V2;
//////////////////////////////////////////////////////
void Main()
{
VAL_1 = 77 + V3*900;
iObjectParamSet(OBJ_0,CENTER_OF_MASS_OFFSET_Y,-0.7 - IN_22*0.004);
///////////////////////////////////////////////////////////////
if (iInitializing())
{
V3= V1;
//////////////////////////////////////////////////////
}
if (iKeyDown(iKeyCode("DIK_End")))
{
V3 = iFloatTendTo(V3,V1,-0.07,V2,0);
//////////////////////////////////////////////////////
iObjectParamSet(OBJ_0,MAX_CAR_SPEED,160*V3*0.5);
iObjectParamSet(OBJ_0,MAX_AXLE_TORQUE_FRONT,1);
iObjectParamSet(OBJ_0,MAX_AXLE_TORQUE_REAR,1);
iObjectParamSet(OBJ_0,SUSPENSION_TRAVEL_FRONT,0.71 + V3);
iObjectParamSet(OBJ_0,SUSPENSION_TRAVEL_REAR,0.71 + V3);
iObjectParamSet(OBJ_0,SUSPENSION_TARGET_FRONT,0.01 + V3);
iObjectParamSet(OBJ_0,SUSPENSION_TARGET_REAR,0.01 + V3);
}
else if (iKeyDown(iKeyCode("DIK_Home")))
{
V3 = iFloatTendTo(V3,-0.07,V1,V2,0);
//////////////////////////////////////////////////////
iObjectParamSet(OBJ_0,MAX_CAR_SPEED,160*V3*50);
iObjectParamSet(OBJ_0,MAX_AXLE_TORQUE_FRONT,0.5);
iObjectParamSet(OBJ_0,MAX_AXLE_TORQUE_REAR,0.5);
iObjectParamSet(OBJ_0,SUSPENSION_TRAVEL_FRONT,0.71 + V3);
iObjectParamSet(OBJ_0,SUSPENSION_TRAVEL_REAR,0.71 + V3);
iObjectParamSet(OBJ_0,SUSPENSION_TARGET_FRONT,0.01 + V3);
iObjectParamSet(OBJ_0,SUSPENSION_TARGET_REAR,0.01 + V3);
}
}
Here is a script I put together that lets a cars suspensions riser/lower by pressing home or end.
it obviously works while the car is idle or while it's moving and no need to reset the car just to have the changes to be applied.
« Last Edit: May 02, 2014, 04:44:58 PM by dogtorque »
I be trippin!
« Reply #1 on: May 02, 2014, 10:32:52 AM »
Awesome!  Thanks dogtorque.  I'll be sure to use this in some of my later projects.
Lego enthusiast, 3d game developer, and animator.
« Reply #2 on: May 02, 2014, 10:33:15 AM »
Yeah! That's sweet! How did you come up with such great script? I didn't know its even possible with 3DRad
« Reply #3 on: May 02, 2014, 12:26:33 PM »
Yeah! That's sweet! How did you come up with such great script? I didn't know its even possible with 3DRad
well I was working on another project on 3drad and I just wondered what if I could switch to a Higher or lower ride height so what I did was looked.

and then I just did a lot of test and rewrites for this script this one is the newest version. the previous one wasn't able to slowly lower or raise it.

it was more instant and effected the car because the wheels would leave the ground and that made it almost impossible to turn when there is a curve in the road. so then I just kept that one just in case and started a new one. and then I seen how the slow motion script that omarkronos (http://www.3drad.com/forum/index.php?topic=8366.0) created several years ago  gradually slowed down and I had a Idea that maybe I could use some of the stuff from the to make my script work properly so I copied it down and basicly heavily modified it to work with the suspension travel instead of the simulation speed and that's how this script was made.

lol hopefully that explanation is good enough for you.
or were you just being sarcastic.
I be trippin!
« Reply #4 on: May 02, 2014, 06:01:18 PM »
here is a video of the script applied to a pcar if you want to see a vid instead of just the screenshot.
https://www.youtube.com/watch?v=T-BjTq9mr8w&list=UUr0boUODFnZmY-PWnSyMokg
I be trippin!
Pages: [1]