i have a simple car which i set wheel collider to the wheels and the mesh under (the road) is mash collider
i set here is my configuration in pictures :
the car config
here is the wheel collider config :
here is the body as box collider :
and this is the result when i hit play :
and the script that attached to the car :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Car : MonoBehaviour
{
public WheelCollider wheelColliderLeftFront;
public WheelCollider wheelColliderRightFront;
public WheelCollider wheelColliderLeftBack;
public WheelCollider wheelColliderRightBack;
public Transform wheelLeftFront;
public Transform wheelRightFront;
public Transform wheelLeftBack;
public Transform wheelRightBack;
public float motorTorque = 100f;
public float maxSteer = 20f;
//public Transform centerOfMess;
//private Rigidbody _rigidbody;
void Start()
{
//_rigidbody = GetComponent<Rigidbody>();
//_rigidbody.centerOfMass = centerOfMess.localScale;
}
void FixedUpdate()
{
wheelColliderLeftBack.motorTorque = Input.GetAxis("Vertical") * motorTorque;
wheelColliderRightBack.motorTorque = Input.GetAxis("Vertical") * motorTorque;
wheelColliderLeftFront.steerAngle = Input.GetAxis("Horizontal") * maxSteer;
wheelColliderRightFront.steerAngle = Input.GetAxis("Horizontal") * maxSteer;
}
private void Update()
{
var pos = Vector3.zero;
var rot = Quaternion.identity;
wheelColliderLeftFront.GetWorldPose(out pos, out rot);
wheelLeftFront.position = pos;
wheelLeftFront.rotation = rot;
wheelColliderRightFront.GetWorldPose(out pos, out rot);
wheelRightFront.position = pos;
wheelRightFront.rotation = rot;
wheelColliderLeftBack.GetWorldPose(out pos, out rot);
wheelLeftBack.position = pos;
wheelLeftBack.rotation = rot;
wheelColliderRightBack.GetWorldPose(out pos, out rot);
wheelRightBack.position = pos;
wheelRightBack.rotation = rot;
}
}
why is that happening?
how can I fix this? i want to understand what i did wrong?
Thanks



