|
Post by Moidar on May 9, 2016 0:47:32 GMT
Hi everyone, I just wanted to ask if anyone had that one Script that made my steering wheel rotate. I worked like this: You needed to have 2 skinmeshes in the same place, and a Car, only one of them (skinmeshes) could be connected to the Car. And yess, I had that script bevore I formated my PC.. sadly forgot to copy my 3drad folder.. Thanks in Advance! Update--------------------------------------------------------> Actually managed to write the Script by myself: Quaternion DeltaOrientation; Vector3 DeltaLocation; void Main() { Vector3 spriteLocation; Quaternion orientation; Vector3 location; Quaternion x90Rotation; Quaternion spriteOrientation; Quaternion vehicleOrientation; float zero = 180; float range = 12; { iQuaternionFromEulerAngles(DeltaOrientation,180,180,zero-IN_24*range,"xyz"); spriteLocation = Vector3(0,0,0); iObjectOrientation(OBJ_44,spriteOrientation); iObjectLocation(OBJ_44,spriteLocation); Quaternion objectOrientation; Vector3 objectLocation; iQuaternionMultiply(objectOrientation,DeltaOrientation,spriteOrientation); iVectorRotate(objectLocation,DeltaLocation,spriteOrientation); objectLocation += spriteLocation; iObjectOrientationSet(OBJ_0,objectOrientation); iObjectLocationSet(OBJ_0,objectLocation); } }
|
|
|
Post by Thunder on May 9, 2016 15:56:40 GMT
Do you mean car controlled by a steering wheel?
|
|
|
Post by bartyrocks3 on May 9, 2016 20:59:45 GMT
I still have that script saved. Here: //Orient a sprite based on current heading of a car
void Main()
{
Quaternion spriteOrientation;
Quaternion x90Rotation;
Quaternion vehicleOrientation;
iQuaternionFromEulerAngles(x90Rotation,-ยญ90,0,0,"xyz"); //create a quaternion rotating -90 degs about X
iObjectOrientation(OBJ_3,vehicleOrientatยญion); //get vehicle orientation
iQuaternionMultiply(spriteOrientation,veยญhicleOrientation,x90Rotation); // rotate the quaternion to transform from XZ plane to XY plane
iObjectOrientationSet(OBJ_0,spriteOrientยญation);
} If you have any problems, I found this youtube video on how to use it. Click Here to watch that video on youtube.
|
|
|
Post by Moidar on May 11, 2016 14:46:55 GMT
I mean a Script that needed to use 2 Skinmeshes for it to work, this one is for a sprite (i think).
|
|
|
Post by WhyNot on May 11, 2016 15:59:07 GMT
you want to add skinmesh to your car's wheels then'\ rightclick on the center of a wheel and add a wheel skinmesh and link it to car same thing to all of wheels and you've got this!!!
|
|
|
Post by Moidar on May 11, 2016 16:46:19 GMT
Nope, it just needs 2 skinmeshes, one is connected to the car, both are connected to the script, and the script somehow reads the position of the one connected to the car to the one that is gonna be the visible skinmesh, that is gonna just rotate left&right, nothing more.
void Main()
{
Quaternion x90Rotation;
Quaternion spriteOrientation;
Quaternion vehicleOrientation;
float zero = 180;
float range = -12;
iQuaternionFromEulerAngles(spriteOrientation,180,0,zero-IN_24*range,"xyz");
iObjectOrientationSet(OBJ_0,spriteOrientation);
}
thats the script I wrote, the Steering Wheel is rotating to the left and right, but is not "fixed" with the car and rotates in all other angles and so on. But follows the car .
|
|
|
Post by Moidar on May 11, 2016 19:18:33 GMT
YESSS FINALLY DID IT!!!
I managed to write dat script ahaha xdd (I'm just a bit excited)
SCRIPT:
Quaternion DeltaOrientation;
Vector3 DeltaLocation;
void Main()
{
Vector3 spriteLocation;
Quaternion orientation;
Vector3 location;
Quaternion x90Rotation;
Quaternion spriteOrientation;
Quaternion vehicleOrientation;
float zero = 180;
float range = 12;
{ iQuaternionFromEulerAngles(DeltaOrientation,180,180,zero-IN_24*range,"xyz");
spriteLocation = Vector3(0,0,0);
iObjectOrientation(OBJ_44,spriteOrientation);
iObjectLocation(OBJ_44,spriteLocation);
Quaternion objectOrientation;
Vector3 objectLocation;
iQuaternionMultiply(objectOrientation,DeltaOrientation,spriteOrientation);
iVectorRotate(objectLocation,DeltaLocation,spriteOrientation);
objectLocation += spriteLocation;
iObjectOrientationSet(OBJ_0,objectOrientation);
iObjectLocationSet(OBJ_0,objectLocation);
}
}
|
|
|
Post by WhyNot on May 12, 2016 9:51:10 GMT
yesh cool
|
|
|
Post by NicusorN5 on May 28, 2016 7:01:33 GMT
Close this thread?
|
|
|
Post by Moidar on May 30, 2016 21:31:14 GMT
Yes
|
|