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: How do you make a skinmesh steering turn when turning the wheel on the car  (Read 393 times)

« on: November 24, 2013, 11:53:04 AM »
is there a script or something i need , im still learning
« Reply #1 on: November 25, 2013, 10:56:25 AM »
Do you mean steering wheel?

anyway, for steering wheel you will need this script
Code: [Select]
void Main()
{
  Quaternion speedOrientation;
  Quaternion spriteOrientation;
  Quaternion carOrientation;
  float zero = -0; //gauge position when speed is zero
  float range = 8; //gauge range (in degrees) for each meter per second
iQuaternionFromEulerAngles(speedOrientation,0,0,zero+IN_X*range,"xyz");
  iObjectOrientation(OBJ_X,carOrientation);
iQuaternionMultiply(spriteOrientation,speedOrientation,carOrientation);
  iObjectOrientationSet(OBJ_Y,spriteOrientation);
  }

where IN_X is steering angle.
         OBJ_X is a Car object
         OBJ_Y is a skinmesh (steering wheel)
My current project - 70s style car chase : The Good Old Chase - San Francisco
« Reply #2 on: November 25, 2013, 11:06:44 AM »
even simpler solution...

Code: [Select]

float  targetAngl, angl;

void Main()
{
   LocalToParent(OBJ_0,OBJ_22,Vector3(0,angl*-0.5,0),Vector3(0,1,-1));
   LocalToParent(OBJ_0,OBJ_44,Vector3(0,0,angl),Vector3(0,0.6,-0.4));

   targetAngl=0;
   if(iKeyDown(iKeyCode("DIK_RIGHT")))targetAngl=-60;
   if(iKeyDown(iKeyCode("DIK_LEFT")))targetAngl=60;
   if(angl>targetAngl)angl-=2;
   if(angl<targetAngl)angl+=2;
}

of course you'll need Jestermon's LocalToParent() and function (i suggest you keep this and use it regularly)

the entire steering wheel thingee is attached as a .3dr


--Mike

« Reply #3 on: November 29, 2013, 11:06:32 AM »
 :) thanks for the script ,
« Reply #4 on: November 30, 2013, 09:25:28 PM »
Definitely those are easier than i have to suggest, but here's my 2 cents :)...

Use a wheel object and attach it to the car, put the wheel object where the steering wheel should be, and rotate it in a way that when you press the turning keys, the wheel swings left or right, now put the skinmesh there ad attach it to the wheel and then hide the wheel, done!

I'll just post a picture if you want, but this method is because I didn't know how to get round this in scripting :) :P
« Reply #5 on: December 22, 2013, 01:07:14 AM »
Ahhh haaa , Hawk.. thats too simple.. sweet

I actually played with this idea before with my rubics cube project, by using a wheel object to swing the cube left & Right for viewing the sides..
Pages: [1]