x


Turning tire slip to car rotation

I got a problem with a script that makes tireslips, They appear below the tires but they doesnt turn accordingly to the tire.

code:

var rot : Quaternion = Quaternion(0,transform.rotation.x,0,transform.rotation.z);
var slipDir = GameObject.Find("Slips");
//var rot : Quaternion = Quaternion.Euler(0,transform.localRotation.x ,0);
if ( Mathf.Abs( CorrespondingGroundHit.sidewaysSlip ) > 4 ) {
    if ( SlipPrefab ) {
       var slip = Instantiate( SlipPrefab, CorrespondingGroundHit.point + (CorrespondingGroundHit.normal * floatontop), rot );
       slip.transform.parent = slipDir.transform;
    }
}

This code makes the slip turn along the Z axis, I have tried to make a quaternion with the rotation along y as a value and 0 on x and z but that didnt work.

If I change this line:

var rot : Quaternion = Quaternion(0,transform.rotation.x,0,transform.rotation.z);

then the slip turn 90 degrees wrong and I have tried to add 90 to that line but it only changes back to the usual rotation along the z. (The wheel isnt turning along the y but the x, its turned 90 degrees)

And if there is any easier way or better way to do this I'd appreciate if you could tell me. :)

more ▼

asked Jun 28 '12 at 01:07 PM

multinfs gravatar image

multinfs
21 7 12 13

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2171
x1259
x62
x9

asked: Jun 28 '12 at 01:07 PM

Seen: 352 times

Last Updated: Jun 28 '12 at 01:44 PM