Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Reloaded23 · Jan 28, 2014 at 12:34 PM · rigidbodycarwheelcollider

car not moving straight

I am trying to make a simple car game but whenever i am pressing up arrow the car is moving to right. This is the code i am using and attached to the car gameobject

 public WheelCollider wheelFL, wheelFR, wheelRL, wheelRR;
     
     public float maxTorque = 50f;
     public float steerFactor = 10f;
 
     void Start () 
     {
         rigidbody.mass = 1500f;
         rigidbody.centerOfMass = new Vector3(0f, -0.9f, 0f);
     }
     
     void FixedUpdate () 
     {
         wheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical");
         wheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical");
         
         wheelFL.steerAngle = steerFactor * Input.GetAxis("Horizontal");
         wheelFR.steerAngle = steerFactor * Input.GetAxis("Horizontal");
         
     }

Here is how wheel colliders are set wheels

wheels.jpg (20.9 kB)
Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sethuraj · Jan 28, 2014 at 12:57 PM 0
Share

As from the image I guess your current car rig is not set up as the front of the car aligned towards the forward vector (Z).Its aligned towards the right vector(X).So pressing forward on keyboard will translate the car in forward vector globally which is currently the along the right side of ur car. You should re-rig the car so that the front of the car should face towards positive Z axis...

avatar image kjuuz · Jan 28, 2014 at 12:59 PM 0
Share

I didn't tested the script, but read this: RigidBody.mass

Try to change Rigidbody.mass = 1; in docs said that you should use between 0,1 and 10. Never larger then 10.

Edit: sethuraj is right, you should set cars front pointing Z axis not X.

avatar image Reloaded23 · Jan 28, 2014 at 02:02 PM 0
Share

ok i will try to change the direction of car to z and will let u know if it solves anything. $$anonymous$$oreover i found this link http://forum.unity3d.com/threads/62495-Question-about-WheelCollilder-vehicle-not-going-straight

where it says change the settings of wheel collider

After changing the settings it is working fine but now i am facing some new problem.

when car is moving some jerk effect is co$$anonymous$$g in the wheel.

avatar image kjuuz · Jan 28, 2014 at 04:03 PM 0
Share

If i understand correct then your wheels are "boucing"? $$anonymous$$aybe because of rigidbody mass? try to change it to 1.0f;

avatar image Reloaded23 · Jan 29, 2014 at 06:49 AM 0
Share

I tried both. 1. Car is facing now in z direction and move towards z but not straight. It is tilting either to left or right. 2. Changing rigidbody mass to 1.0f does not solve the jerk effect

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by VaibhavRocks · Jun 06, 2014 at 04:19 AM

Hey.. does anybody got the solution to this.. please let me know ..even i need urgently

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by florinel2102 · Sep 20, 2020 at 03:18 PM

I fixed by setting to all wheel colliders -- Sideways Friction - Extremum Slip to 0.02

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by zakirshikhli · Apr 13 at 03:09 PM

I fixed that, by dynamically rising sidewayFriction.extremumSlip of Front WheelColliders from 0.2f to ~2.0f - 2.5f according to car speed.

Something like this void Update(){ sideFrictionFront.extremumSlip = 0.2f + (currentSpeed / currentMaxSpeed) * 2; }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zakirshikhli · Apr 13 at 03:12 PM 0
Share

To fix most WheellColliders issues, many numbers there should be dynamically change accorind to speed and assign in real time (Update method): This is just a sample, not a complete solution:

 void AssignWheelPhysics()
         {
              rearLeftCollider.sidewaysFriction = sideFrictionRear;
              rearRightCollider.sidewaysFriction = sideFrictionRear;
     
              frontLeftCollider.sidewaysFriction = sideFrictionFront;
              frontRightCollider.sidewaysFriction = sideFrictionFront;
     
              rearLeftCollider.forwardFriction = forwardFrictionRear;
              rearRightCollider.forwardFriction = forwardFrictionRear;
     
              frontLeftCollider.forwardFriction = forwardFrictionFront;
              frontRightCollider.forwardFriction = forwardFrictionFront;
         }

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Wheel Collider - Mesh/Box Collider Problem 0 Answers

Wheelcolliders launch the car. 0 Answers

how to set initial speed of vehicle 1 Answer

Are y-axis wheelcolliders possible? 1 Answer

Perfect friction with WheelColliders 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges