• 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 tulloch100 · Aug 04, 2017 at 06:41 AM · carwheelcolliderwheel

Car wheels not stopping when I brake

Im creating a kart game and when I stop the kart the wheel dont stop and the kart takes a very long time to stop and reverse alt text

I have a wheel colider on each wheel alt text

 public class Car : MonoBehaviour
 {
     public float maxTorque = 5000f;
     public float speed = 5000f;
 
 
     public Transform centerofMass;
 
     public WheelCollider[] wheelColliders = new WheelCollider[4];
     public Transform[] tireMeshes = new Transform[4];
 
     private Rigidbody m_rigidBody;
 
     void Start()
     {
         m_rigidBody = GetComponent<Rigidbody>();
         m_rigidBody.centerOfMass = centerofMass.localPosition;
     }
 
     void Update()
     {
         UpdateMeshesPositions();
     }
 
     void FixedUpdate()
     {
         float steer = Input.GetAxis ("Horizontal");
         float accelrate = Input.GetAxis ("Vertical");
 
         float finalAngle = steer * 45f;
         wheelColliders [0].steerAngle = finalAngle;
         wheelColliders [1].steerAngle = finalAngle;
 
         for (int i = 0; i < 4; i++)
         {
             wheelColliders[i].motorTorque = accelrate * speed * maxTorque;        }
     }
 
     void UpdateMeshesPositions()
     {
         for(int i = 0; i < 4; i++)
         {
             Quaternion quat;
             Vector3 pos;
             wheelColliders[i].GetWorldPose(out pos, out quat);
 
             tireMeshes[i].position = pos;
             tireMeshes[i].rotation = quat;
         }
     }
 }

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

67 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 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 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

How do I Instantly stop wheels (WheelCollider) from moving ? 0 Answers

Front wheel rotates in play mode 1 Answer

WheelCollider Setup from car? 0 Answers

C# WheelHit.force display wheel suspensions on meshes 0 Answers

Vehicle issues. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges