Exemple #1
0
 void OnEnable()
 {
     #if UNITY_EDITOR
     if (!Application.isPlaying)
     {
         if (!initialized)
         {
             Debug.Log("initialized");
             initialized = true;
             body        = gameObject.GetComponent <Rigidbody>();
             gameObject.GetComponent <VehicleUserController>().SetVehicle(this);
             if (!createInEditorWindow)
             {
                 TryToSet();
             }
         }
     }
     else
     {
     #endif
     foreach (var item in GetComponentsInChildren <Rigidbody>())
     {
         item.maxAngularVelocity = 50.0f;
     }
     velocityMPS       = 0.0f;
     body.centerOfMass = centerOfMass.localPosition;
     vehicleController = GetComponent <VehicleUserController>();
     #if UNITY_EDITOR
 }
     #endif
     OnTrigger(true);
 }
Exemple #2
0
        protected virtual void Awake()
        {
            animator = GetComponent <Animator>();
            vehicle  = transform.root.GetComponent <Vehicle>();
            if (!vehicle)
            {
                enabled = false;
                return;
            }
            steering = vehicle.GetComponentInChildren <Steering>();
            if (!steering)
            {
                enabled = false;
                return;
            }

            Collider bodyCollider  = GetComponentInParent <Vehicle>().bodyCollider;
            Collider crashCollider = GetComponentInChildren <CrashChecker>().GetComponent <Collider>();

            vehicleController = GetComponentInParent <VehicleUserController>();

            foreach (var item in driverPhysics.GetComponentsInChildren <Collider>())
            {
                Physics.IgnoreCollision(bodyCollider, item);
                Physics.IgnoreCollision(crashCollider, item);
            }
            driverPhysics.OnAwake();
            driverPhysics.SetActive(false);

            driverIK = vehicle.transform.Find("DriverIK");
            driver   = vehicle.transform.Find("Driver");
        }