Пример #1
0
        //Init field of objects
        protected virtual void InitVehicle()
        {
            rb           = GetComponent <Rigidbody>();
            pb           = GetComponent <Physicsbody>();
            objectHeight = 2f;// GetComponent<MeshFilter>().mesh.bounds.extents.z;

            //Configure rb so it doesnt do stupid shit like gravity
            rb.useGravity = false;

            //Allocate Centre of Gravity
            if (rb && centreOfGravity)
            {
                rb.centerOfMass = centreOfGravity.localPosition;
            }

            //Set up some cameras!
            cameraGroup = transform.Find("Cameras");

            if (cameraGroup)
            {
                cameras = new Transform[cameraGroup.transform.childCount];

                if (cameras.Length > 0)
                {
                    foreach (Transform _child in cameraGroup)
                    {
                        if (_child == null)
                        {
                            continue;
                        }

                        cameras[cameraCount] = _child;
                        cameraCount++;
                    }
                    cam = cameras[0];
                }
                else
                {
                    Debug.LogWarning(name + " found camera group but no cameras- don't forget to add some!");
                }
            }
            else
            {
                Debug.LogWarning(name + " Did not find a camera group- is this object properly initializsed?");
            }
        }
 private void OnEnable()
 {
     targetInput = (Physicsbody)target;
 }
Пример #3
0
 protected virtual void Start()
 {
     rb = GetComponent <Rigidbody>();
     pb = GetComponent <Physicsbody>();
 }