#Wheel collider goes crazy

1 messages · Page 1 of 1 (latest)

tired remnant
#

Hi guys, I tried setting up my car.
However, whenever I hit play and the car touches the mesh collider or a box collider, it goes absolutely crazy and I cant figure out why.
heres the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CarController : MonoBehaviour
{
    public WheelCollider[] wheels = new WheelCollider[4];
    public float torque = 200;
    private void Start()
    {
        
    }

    private void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.W))
        {
            for (int i = 0; i < wheels.Length; i++)
                wheels[i].motorTorque = torque; ;
        } else
        {
            for (int i = 0; i < wheels.Length; i++)
                wheels[i].motorTorque = 0; 
        }
    }

}
weak lark
#

use edy's vehicle physics, for example the free community edition, to get started with vehicles in unity

#

there you can learn how to configure wheels

tired remnant
#

any free options, i dont feel like paying 30 just for setting up the cars

weak lark
#

i think vehicle physics community edition is authored by edy and is free

#

there is also a car set up in the unity standard assets

tired remnant
weak lark
#

maybe your floor is busted

tired remnant
weak lark
#

are you using his vehicle as an example

#

i do this stuff all the time

tired remnant
#

I've figured out that the rigidbody doesn't cause the problem

weak lark
#

why are you setting up the car from scratch?

#

start with the prefab

#

and study how it is structured

tired remnant
#

But as soon as I activate the wheelcolliders again, it sends the car flying

weak lark
#

answer this question with a simple yes or no: are you using one of his example prefabs?

#

i've asked you 3 times

tired remnant
#

Yes, I did and it worked fine

weak lark
#

okay

#

so it goes without saying that this configuration is arbitrary

#

you can't just figure it out

#

start with the sample hierarchy

#

one thing you absolutely cannot do is attach the wheel colliders to a real mesh

#

unless your mesh is perfect, you attach them to transforms that are oriented correctly

#

that have all the right orientations, 1-1-1 scale, symmetric positions, etc.

#

and you can use parent constraints to rig the art wheels to the simulation wheels

#

if that makes sense

tired remnant
#

I have an empty parent object for all the wheel colliders, the car is rigged and everything, each wheelcollider is assigned to an individual object, just like in every tutorial on YouTube

weak lark
#

don't use video tutorials

#

use the sample prefab

#

replace the sample prefab's mesh with yours

#

use its hierarchy as an example

#

i wouldn't be stubborn about this

#

sorry i can't be more helpful. it will be a totally uninteresting configuration issue

tired remnant
#

Okay, I'll look into it tomorrow

#

Thank you so much

weak lark
#

okay

#

if you have some specific issue feel free to ping me and ask

#

the most obvious issue i see is that your front wheel's scale is not 1-1-1, according to the inspector screeshot you shared

#

@tired remnant so by now you should know, with unity, you shoul dnever be using a scale that isn't 1-1-1

#

unless the object is strictly cosmetic, never use a non-1-1-1 scale