Hello, I am using Unity 2019.3.0f5. My car fails to collide with ground . It is the problem mentioned in the question below -
[Car falls through ground Wheel Collider][1]
My car hierarchy is the following -
![car_hierarchy][2]
I have attached a rigidbody to the car (parent), two box colliders to the Collider and transform and WheelCollider accordingly.
Rigidbody -
![rigidbody][3]
Box Collider
![box_collider][4]
(Wheel Collider has default parameters)
And a simple cs script attached the parent object.
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 maxMotorTorque = 100f;
public float maxSteer = 20f;
// Start is called before the first frame update
//void Start()
//{
//}
// Update is called once per frame
void FixedUpdate()
{
wheelColliderLeftBack.motorTorque = Input.GetAxis("Vertical") * maxMotorTorque;
wheelColliderRightBack.motorTorque = Input.GetAxis("Vertical") * maxMotorTorque;
Debug.Log(Input.GetAxis("Vertical"));
}
}
Currently I only want my car to go forward without any turinig any direction. What's the possible way to resolve this issue ?
Source: [Youtube tutorial][5]
[1]: https://answers.unity.com/questions/49535/car-falls-through-ground-wheel-collider.html
[2]: https://i.ibb.co/NsNvPf6/car-hierarchy.png
[3]: https://i.ibb.co/0q158W9/rigidbody.png
[4]: https://i.ibb.co/5Y7VqDP/box-collider.png
[5]: https://www.youtube.com/watch?v=MkOGlTTvaWU&list=PLC7nmYI-cbT1uGmB9_D74VIUh7qN_YsH5&index=10
↧