x


Car Wheels Error/Glitch/BUG, Please help.

Hey Guys. I am creating a racing car game. I have my car functioning 99% well. It drives/stears fantastic. I have a computer car that races with you. It works beautifully. The only issue im having atm is. When i created my car i used the actual spokes inside the rim to be the rotating axis so it looks more real. But when i start the game my rims stick out the side and it looks so goofy. Should i edit my model and make the wheel one object or should i simply move the actual wheel script to a different component. Here is pictures of the actual bug.

This is the car When the rims are being stupid. alt text

This Is The Car Behaving beautifully before i play the game. alt text

So i was wondering if you guys have any information that could help this error. Thank you :)

Wheel working..png (160.5 kB)
Wheel function.png (181.1 kB)
more ▼

asked May 28 '12 at 10:02 AM

AusAndrew19 gravatar image

AusAndrew19
115 14 36 43

have you checked your normals settings?

May 28 '12 at 10:22 AM hirenkacha

by the way good design...

May 28 '12 at 10:24 AM hirenkacha

Thanks mate, I didn't design it i bought this model in a pack. When you say did i check my normal setting what do you mean mate? I'm not too sure on what you mean since im a bit of a noob :)

May 28 '12 at 10:36 AM AusAndrew19
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

Check your wheel colliders pivot and your wheel's pivot if you are making them reference to eachother at runtime.

more ▼

answered May 28 '12 at 10:23 AM

hirenkacha gravatar image

hirenkacha
701 12 19 21

Sorry mate not too sure on what you mean pivit. This is the script for the wheels if this helps.

// Define the variables used in the script, the Corresponding collider is the wheel collider at the position of // the visible wheel, the slip prefab is the prefab instantiated when the wheels slide, the rotation value is the // value used to rotate the wheel around it's axel. var CorrespondingCollider : WheelCollider; var SlipPrefab : GameObject; private var RotationValue : float = 0.0;

function Update () {

// define a hit point for the raycast collision
var hit : RaycastHit;
// Find the collider's center point, you need to do this because the center of the collider might not actually be
// the real position if the transform's off.
var ColliderCenterPoint : Vector3 = CorrespondingCollider.transform.TransformPoint( CorrespondingCollider.center );

// now cast a ray out from the wheel collider's center the distance of the suspension, if it hit something, then use the "hit"
// variable's data to find where the wheel hit, if it didn't, then se tthe wheel to be fully extended along the suspension.
if ( Physics.Raycast( ColliderCenterPoint, -CorrespondingCollider.transform.up, hit, CorrespondingCollider.suspensionDistance + CorrespondingCollider.radius ) ) {
    transform.position = hit.point + (CorrespondingCollider.transform.up * CorrespondingCollider.radius);
}else{
    transform.position = ColliderCenterPoint - (CorrespondingCollider.transform.up * CorrespondingCollider.suspensionDistance);
}

// now set the wheel rotation to the rotation of the collider combined with a new rotation value. This new value
// is the rotation around the axle, and the rotation from steering input.
transform.rotation = CorrespondingCollider.transform.rotation * Quaternion.Euler( RotationValue, CorrespondingCollider.steerAngle, 0 );
// increase the rotation value by the rotation speed (in degrees per second)
RotationValue += CorrespondingCollider.rpm * ( 360/60 ) * Time.deltaTime;

// define a wheelhit object, this stores all of the data from the wheel collider and will allow us to determine
// the slip of the tire.
var CorrespondingGroundHit : WheelHit;
CorrespondingCollider.GetGroundHit( CorrespondingGroundHit );

// if the slip of the tire is greater than 2.0, and the slip prefab exists, create an instance of it on the ground at
// a zero rotation.
if ( Mathf.Abs( CorrespondingGroundHit.sidewaysSlip ) > 2.0 ) {
    if ( SlipPrefab ) {
       Instantiate( SlipPrefab, CorrespondingGroundHit.point, Quaternion.identity );
    }
}

}

May 28 '12 at 10:41 AM AusAndrew19

Sorry if script isnt well presented i dont know how to add it to code box.

May 28 '12 at 11:11 AM AusAndrew19

@AusAndrew : Sorry for late reply. I think your wheelcollider is too much inward. Check with pulling out your wheelcolliders slightly. And check your car model's wheel's center where it is? Wheelcollider's center and your 3d wheel model's center should be get adjusted. It wld woek fine.

Jun 01 '12 at 10:17 AM hirenkacha

Mate, Truly... Thank you! :) I Followed what you said and a little adjusting i got it!! Thank you! :)

Jun 04 '12 at 03:39 PM AusAndrew19
(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x5091
x418
x119

asked: May 28 '12 at 10:02 AM

Seen: 445 times

Last Updated: Jun 04 '12 at 03:39 PM