Car made from Different GameObjects and Empty GameObjects breaks on Collision with Terrain.
I made a Car using the following Hierarchy:
I have the following Empty GameObjects(GO): Car, Tyers, Glass, Body, Lights, Head Lights and Rear Lights.
The rest are Basic 3D GameObjects.
There are three Problems: 1) If I have Only the Car GO with the RigidBody then the Car wont move using the RigidBody.AddForce().
2) If I Make Every Empty GO a RigidBody then the Car Breaks and the Empty GOs fall through the Terrain.
3) If I Make Every GO a RigidBody then also the Car Breaks and the Empty GOs fall through the Terrain.
In 2) and 3) the GOs still DON'T respond to RigidBody.AddForce().
----------
Code Used:
using UnityEngine; using System.Collections;
public class MoveObjectPlayerInputKB : MonoBehaviour {
private Rigidbody car;
public float speed = 0.5F;
public float turnSpeed = 0.5F;
// Use this for initialization
void Start () {
car = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
float turn = Input.GetAxis("Horizontal");
float forward = Input.GetAxis("Vertical");
car.AddForce (new Vector3(0F, 0F, forward) * Time.deltaTime * speed);
transform.Rotate (new Vector3 (0F, turn, 0F) * Time.deltaTime * turnSpeed);
// car.AddTorque (new Vector3 (0F, turn, 0F) Time.deltaTime turnSpeed);
}
}
----------
Thanks in advanced and I also Apologize for asking such a Question as I am New to Unity. It's ONLY been 2 weeks.!
The Result I'm getting.