is there a script or something i need , im still learning
This forum is now archived!
- Welcome to the archive!
News:
The 3DRad community can be found at classdev.net.
- 3D Rad - Free 3D game maker - Forum >
- General Category >
- 3D Rad - Technical Discussion >
- How do you make a skinmesh steering turn when turning the wheel on the car
Author Topic: How do you make a skinmesh steering turn when turning the wheel on the car (Read 393 times)
Do you mean steering wheel?
anyway, for steering wheel you will need this script
where IN_X is steering angle.
OBJ_X is a Car object
OBJ_Y is a skinmesh (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)
even simpler solution...
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
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
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
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
Pages: [1]