Wheel Collider Unity: after adding torque, the car starts moving sideways

I really killed a few hours to try and fix it, googling for a solution, but I couldn’t.

I have a car, this is a trolley, so there are no suspensions (technically there are, but the values ​​are close to 0 to simulate tires). The vehicle has a rigid body, and the children's object contains 4 collider wheels (and the model itself), as can be seen here:

https://dl.dropboxusercontent.com/u/76599014/sxc/Clipboard01.jpg

For testing, I added a short script to make the car move. It is called "gokart" in GameObject:

public class carControler : MonoBehaviour { public WheelCollider fr, fl, rr, rl; public float performance = 50f; void FixedUpdate () { throttle(); } public void throttle() { this.rl.motorTorque = this.performance; this.rr.motorTorque = this.performance; } } 

What happens : rear wheels begin to rotate as intended, but the car begins to slowly sideways strong>. The speed of movement depends on the magnitude of the torque (in this case, the rotation of the wheel). there is no forward movement , therefore it is not a mistake when, when you are standing on a flat surface, you drift on the sides.

Any ideas? If you need a video or GIF (I have to figure out how to do this), I will be happy to provide it.

+6
source share
2 answers

I think you should try applying braking torque 0 to the front wheels by applying engine torque to the rear wheels.

 public void throttle() { this.rl.motorTorque = this.performance; this.rr.motorTorque = this.performance; this.fr.brakeTorque = 0f; this.fl.brakeTorque = 0f; } 

As the saying goes, things can go wrong if the Rigidbody / wheelcolliders are configured incorrectly. Unity wheel colliders can be difficult to set up and operate. Unity has changed physics in Unity 5, so most documents are outdated.

I found this very nice short document made by unity: http://unity3d.com/profiles/unity3d/themes/unity/resources/downloads/beta/unity-5.0-user-guide.pdf

It highlights the changes that have been made for unity 5, and at the end of page 5 you can find a section that explains how to set up the car. I tried it about a month ago in a new unity project, and it worked. the instructions are clear, so try this tutorial and I hope this helps.

Hi

+1
source

Not having an available image, I'm not quite sure about the situation, but my assumption, based on your description, is that you should try to increase lateral friction and slightly correct direct friction to your liking. You should increase lateral friction anyway when you make the cart. As far as I know, most arcade road carts do not drift and behave differently from ordinary race cars. Hope this solves the problem.

0
source

All Articles