static public int get_sprungMass(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.sprungMass);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int GetWorldPose(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.Vector3       a1;
         UnityEngine.Quaternion    a2;
         self.GetWorldPose(out a1, out a2);
         pushValue(l, true);
         pushValue(l, a1);
         pushValue(l, a2);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int set_brakeTorque(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.brakeTorque = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Trackar.WheelDummy"/> class.
        /// </summary>
        /// <param name="col">Col.</param>
        /// <param name="joint">Joint.</param>
        /// <param name="model">Model.</param>
        /// <param name="config">WheelDummyConfigContainer.</param>
        public WheelDummy(WheelCollider col, Transform joint, GameObject model, WheelDummyConfigContainer config)
        {
            if (col == null)
            {
                Debuggar.Error ("WheelDummy: Attempted spawn with null WheelCollider");
                col = new WheelCollider ();
            }
            if(joint == null)
            {
                Debuggar.Error ("WheelDummy: Attempted spawn with null Joint");
                joint = new GameObject ().transform; // lol gg unity
            }
            if(model == null)
            {
                Debuggar.Error ("WheelDummy: Attempted spawn with null Model");
                model = new GameObject ();
            }
            if(config == null)
            {
                Debuggar.Error ("WheelDummy: Attempted spawn with null WheelDummyConfigContainer");
                config = new WheelDummyConfigContainer ();
            }

            Collider = col;
            Joint = joint;
            WheelModel = model;
            Susp = config.SuspConfig;

            Collider.enabled = true;
            Collider.brakeTorque = config.RollingResistance;
            Debuggar.Message ("WheelDummy: brakeTorque is " + Collider.brakeTorque.ToString () + " RollingResistance is " + config.RollingResistance.ToString ());

            Debuggar.Message ("WheelDummy: Spawned");
        }
 public override void OnInitialize()
 {
     wheelCollider = part.FindModelTransform(wheelColliderName).GetComponent<WheelCollider>();
       updateVesselLegs(vessel);
       if (offset.y != 0)
     wheelCollider.transform.position -= offset.y * wheelCollider.transform.up;
       GameEvents.onVesselChange.Add(updateVesselLegs);
 }
Exemplo n.º 6
0
 static public int get_forceAppPointDistance(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.forceAppPointDistance);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 7
0
 static public int get_radius(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.radius);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider o;
         o=new UnityEngine.WheelCollider();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider o;
         o=new UnityEngine.WheelCollider();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            _wc = go.GetComponent<WheelCollider>();

            _setProperties();

            if(!everyFrame)
            {
                Finish();
            }
        }
Exemplo n.º 11
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider o;
         o = new UnityEngine.WheelCollider();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 12
0
 static public int set_steerAngle(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.steerAngle = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 13
0
 static public int set_suspensionSpring(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.JointSpring   v;
         checkValueType(l, 2, out v);
         self.suspensionSpring = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 14
0
 static public int set_center(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.Vector3       v;
         checkType(l, 2, out v);
         self.center = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 15
0
 static public int set_sidewaysFriction(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider      self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.WheelFrictionCurve v;
         checkValueType(l, 2, out v);
         self.sidewaysFriction = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 16
0
 static void WheelCollider_sidewaysFriction(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
         var result = _this.sidewaysFriction;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.WheelFrictionCurve arg0  = (UnityEngine.WheelFrictionCurve)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.WheelCollider      _this = (UnityEngine.WheelCollider)vc.csObj;
         _this.sidewaysFriction = arg0;
     }
 }
Exemplo n.º 17
0
// fields

// properties
    static void WheelCollider_center(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
            var result = _this.center;
            JSApi.setVector3S((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Vector3       arg0  = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
            _this.center = arg0;
        }
    }
Exemplo n.º 18
0
 static void WheelCollider_suspensionDistance(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
         var result = _this.suspensionDistance;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single             arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
         _this.suspensionDistance = arg0;
     }
 }
Exemplo n.º 19
0
 static void WheelCollider_suspensionSpring(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
         var result = _this.suspensionSpring;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.JointSpring   arg0  = (UnityEngine.JointSpring)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.WheelCollider _this = (UnityEngine.WheelCollider)vc.csObj;
         _this.suspensionSpring = arg0;
     }
 }
Exemplo n.º 20
0
 static public int GetGroundHit(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.WheelHit      a1;
         var ret = self.GetGroundHit(out a1);
         pushValue(l, ret);
         pushValue(l, a1);
         return(2);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 21
0
        public override Status Update () {
            // Get the transform
            if (m_WheelCollider == null || m_WheelCollider.gameObject != gameObject.Value)
                m_WheelCollider = gameObject.Value != null ? gameObject.Value.GetComponent<WheelCollider>() : null;

            // Validate members?
            if  (m_WheelCollider == null || newValue.isNone) {
                return Status.Error;
            }

            // Set the motorTorque
            m_WheelCollider.motorTorque = newValue.Value;

            return Status.Success;
        }
Exemplo n.º 22
0
 static public int GetGroundHit(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.WheelHit      a1;
         var ret = self.GetGroundHit(out a1);
         pushValue(l, true);
         pushValue(l, ret);
         pushValue(l, a1);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 23
0
 static public int GetWorldPose(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.Vector3       a1;
         UnityEngine.Quaternion    a2;
         self.GetWorldPose(out a1, out a2);
         pushValue(l, a1);
         pushValue(l, a2);
         return(2);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 24
0
 static public int GetWorldPose(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         UnityEngine.Vector3       a1;
         UnityEngine.Quaternion    a2;
         self.GetWorldPose(out a1, out a2);
         pushValue(l, true);
         pushValue(l, a1);
         pushValue(l, a2);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go != null)
            {
                _wheel = go.GetComponent<WheelCollider>();
            }

            DoGetGroundHit();

            if (!everyFrame)
            {
                Finish();
            }
        }
Exemplo n.º 26
0
 static public int ConfigureVehicleSubsteps(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         System.Single             a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         self.ConfigureVehicleSubsteps(a1, a2, a3);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 27
0
 static public int ConfigureVehicleSubsteps(IntPtr l)
 {
     try {
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         System.Single             a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         self.ConfigureVehicleSubsteps(a1, a2, a3);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 28
0
        private void Start()
        {
            skidParticles = transform.root.GetComponentInChildren<ParticleSystem>();

            if (skidParticles == null)
            {
                Debug.LogWarning(" no particle system found on car to generate smoke particles");
            }
            else
            {
                skidParticles.Stop();
            }

            m_WheelCollider = GetComponent<WheelCollider>();
            m_AudioSource = GetComponent<AudioSource>();
            PlayingAudio = false;

            if (skidTrailsDetachedParent == null)
            {
                skidTrailsDetachedParent = new GameObject("Skid Trails - Detached").transform;
            }
        }
 static public int ConfigureVehicleSubsteps(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.WheelCollider self = (UnityEngine.WheelCollider)checkSelf(l);
         System.Single             a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         self.ConfigureVehicleSubsteps(a1, a2, a3);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.WheelCollider wheelCollider = (UnityEngine.WheelCollider)value;
     writer.WriteProperty("center", wheelCollider.center);
     writer.WriteProperty("radius", wheelCollider.radius);
     writer.WriteProperty("suspensionDistance", wheelCollider.suspensionDistance);
     writer.WriteProperty("suspensionSpring", wheelCollider.suspensionSpring);
     writer.WriteProperty("forceAppPointDistance", wheelCollider.forceAppPointDistance);
     writer.WriteProperty("mass", wheelCollider.mass);
     writer.WriteProperty("wheelDampingRate", wheelCollider.wheelDampingRate);
     writer.WriteProperty("forwardFriction", wheelCollider.forwardFriction);
     writer.WriteProperty("sidewaysFriction", wheelCollider.sidewaysFriction);
     writer.WriteProperty("motorTorque", wheelCollider.motorTorque);
     writer.WriteProperty("brakeTorque", wheelCollider.brakeTorque);
     writer.WriteProperty("steerAngle", wheelCollider.steerAngle);
     writer.WriteProperty("enabled", wheelCollider.enabled);
     writer.WriteProperty("isTrigger", wheelCollider.isTrigger);
     writer.WriteProperty("contactOffset", wheelCollider.contactOffset);
     writer.WriteProperty("material", wheelCollider.material);
     writer.WriteProperty("sharedMaterial", wheelCollider.sharedMaterial);
     writer.WriteProperty("tag", wheelCollider.tag);
     writer.WriteProperty("name", wheelCollider.name);
     writer.WriteProperty("hideFlags", wheelCollider.hideFlags);
 }
Exemplo n.º 31
0
 static public int get_suspensionSpring(IntPtr l)
 {
     UnityEngine.WheelCollider o = (UnityEngine.WheelCollider)checkSelf(l);
     pushValue(l, o.suspensionSpring);
     return(1);
 }
Exemplo n.º 32
0
        private void antiRoll(WheelCollider _colliderLeft, WheelCollider _colliderRight, float _antiRollValue)
        {
            WheelHit wHit;
            float travelL = 1.0f;
            float travelR = 1.0f;

            bool groundedL = _colliderLeft.GetGroundHit(out wHit);
            if (groundedL)
            {
                travelL = (-_colliderLeft.transform.InverseTransformPoint(wHit.point).y - _colliderLeft.radius) /_colliderLeft.suspensionDistance;
            }
            bool groundedR = _colliderRight.GetGroundHit(out wHit);
            if (groundedR)
            {
                travelR = (-_colliderRight.transform.InverseTransformPoint(wHit.point).y - _colliderRight.radius)/_colliderRight.suspensionDistance;
            }
            float antirollForce = (travelL - travelR) * _antiRollValue;

            if (groundedL) rb.AddForceAtPosition(_colliderLeft.transform.up * -antirollForce, _colliderLeft.transform.position);
            if (groundedR) rb.AddForceAtPosition(_colliderRight.transform.up * antirollForce, _colliderRight.transform.position);
        }
Exemplo n.º 33
0
        private void updateWheelObject(WheelCollider _collider)
        {
            if (_collider.transform.childCount == 0)
            {
                CustomDebug.customLog(this.GetType().Name, "updateWheelObject()", "collider child count is 0");
                return;
            }

            Transform wheelObjectTransform = _collider.transform.GetChild(0);
            Vector3 pos;
            Quaternion rot;

            _collider.GetWorldPose(out pos, out rot);

            wheelObjectTransform.position = pos;
            wheelObjectTransform.rotation = rot;
        }
Exemplo n.º 34
0
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor || state == StartState.None) return;

            SetupParticles();
            if (scrapeSparks)
                SetupLight();

            if (part.Modules.Contains("ModuleWheel")) // Suppress the log message on failure.
                moduleWheel = part.Modules["ModuleWheel"] as ModuleWheel;
            wheelCollider = part.GetComponent<WheelCollider>();
            if (wheelCollider == null)
            {
                ModuleLandingGear gear = part.GetComponent<ModuleLandingGear>();
                if (gear != null)
                {
                    wheelCollider = gear.wheelCollider;
                }
            }

            SetupAudio();

            GameEvents.onGamePause.Add(OnPause);
            GameEvents.onGameUnpause.Add(OnUnpause);

            #if DEBUG
            for (int i = 0; i < spheres.Length; i++)
            {
                spheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                Destroy(spheres[i].collider);
            }
            spheres[0].renderer.material.color = Color.red;
            spheres[1].renderer.material.color = Color.green;
            #endif
        }
Exemplo n.º 35
0
 static public int get_sidewaysFriction(IntPtr l)
 {
     UnityEngine.WheelCollider o = (UnityEngine.WheelCollider)checkSelf(l);
     pushValue(l, o.sidewaysFriction);
     return(1);
 }
Exemplo n.º 36
0
 static public int get_brakeTorque(IntPtr l)
 {
     UnityEngine.WheelCollider o = (UnityEngine.WheelCollider)checkSelf(l);
     pushValue(l, o.brakeTorque);
     return(1);
 }
Exemplo n.º 37
0
 static public int get_isGrounded(IntPtr l)
 {
     UnityEngine.WheelCollider o = (UnityEngine.WheelCollider)checkSelf(l);
     pushValue(l, o.isGrounded);
     return(1);
 }
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.WheelCollider wheelCollider = (UnityEngine.WheelCollider)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "center":
                    wheelCollider.center = reader.ReadProperty <UnityEngine.Vector3> ();
                    break;

                case "radius":
                    wheelCollider.radius = reader.ReadProperty <System.Single> ();
                    break;

                case "suspensionDistance":
                    wheelCollider.suspensionDistance = reader.ReadProperty <System.Single> ();
                    break;

                case "suspensionSpring":
                    wheelCollider.suspensionSpring = reader.ReadProperty <UnityEngine.JointSpring> ();
                    break;

                case "forceAppPointDistance":
                    wheelCollider.forceAppPointDistance = reader.ReadProperty <System.Single> ();
                    break;

                case "mass":
                    wheelCollider.mass = reader.ReadProperty <System.Single> ();
                    break;

                case "wheelDampingRate":
                    wheelCollider.wheelDampingRate = reader.ReadProperty <System.Single> ();
                    break;

                case "forwardFriction":
                    wheelCollider.forwardFriction = reader.ReadProperty <UnityEngine.WheelFrictionCurve> ();
                    break;

                case "sidewaysFriction":
                    wheelCollider.sidewaysFriction = reader.ReadProperty <UnityEngine.WheelFrictionCurve> ();
                    break;

                case "motorTorque":
                    wheelCollider.motorTorque = reader.ReadProperty <System.Single> ();
                    break;

                case "brakeTorque":
                    wheelCollider.brakeTorque = reader.ReadProperty <System.Single> ();
                    break;

                case "steerAngle":
                    wheelCollider.steerAngle = reader.ReadProperty <System.Single> ();
                    break;

                case "enabled":
                    wheelCollider.enabled = reader.ReadProperty <System.Boolean> ();
                    break;

                case "isTrigger":
                    wheelCollider.isTrigger = reader.ReadProperty <System.Boolean> ();
                    break;

                case "contactOffset":
                    wheelCollider.contactOffset = reader.ReadProperty <System.Single> ();
                    break;

                case "material":
                    if (wheelCollider.material == null)
                    {
                        wheelCollider.material = reader.ReadProperty <UnityEngine.PhysicMaterial> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.PhysicMaterial> (wheelCollider.material);
                    }
                    break;

                case "sharedMaterial":
                    if (wheelCollider.sharedMaterial == null)
                    {
                        wheelCollider.sharedMaterial = reader.ReadProperty <UnityEngine.PhysicMaterial> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.PhysicMaterial> (wheelCollider.sharedMaterial);
                    }
                    break;

                case "tag":
                    wheelCollider.tag = reader.ReadProperty <System.String> ();
                    break;

                case "name":
                    wheelCollider.name = reader.ReadProperty <System.String> ();
                    break;

                case "hideFlags":
                    wheelCollider.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> ();
                    break;
                }
            }
        }
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.WheelCollider wheelCollider = SaveGameType.CreateComponent <UnityEngine.WheelCollider> ();
     ReadInto(wheelCollider, reader);
     return(wheelCollider);
 }
Exemplo n.º 40
0
        //OnStart
        public override void OnStart(PartModule.StartState state)
        {
            _KFModuleWheel = part.GetComponentInChildren<KFModuleWheel>();
            tweakScaleCorrector = _KFModuleWheel.tweakScaleCorrector;

            if (!isConfigured)
            {
                foreach (WheelCollider wc in part.GetComponentsInChildren<WheelCollider>())
                {
                    if (wc.name.StartsWith(colliderName, StringComparison.Ordinal))
                    {
                        _wheelCollider = wc;
                        suspensionDistance = wc.suspensionDistance;

                        #if DEBUG
                        KFLog.Log(string.Format("SuspensionDistance is: {0}.", suspensionDistance));
                        #endif

                        isConfigured = true;
                    }
                }
            }

            if (HighLogic.LoadedSceneIsFlight && !Equals(vessel.vesselType, VesselType.Debris))
            {
                GameEvents.onGamePause.Add(new EventVoid.OnEvent(OnPause));
                GameEvents.onGameUnpause.Add(new EventVoid.OnEvent(OnUnPause));

                // Find named onjects in part.
                foreach (WheelCollider wc in part.GetComponentsInChildren<WheelCollider>())
                {
                    if (wc.name.StartsWith(colliderName, StringComparison.Ordinal))
                        _wheelCollider = wc;
                }

                foreach (Transform tr in part.GetComponentsInChildren<Transform>())
                {
                    if (tr.name.StartsWith(wheelName, StringComparison.Ordinal))
                        _wheel = tr;
                    if (tr.name.StartsWith(steeringName, StringComparison.Ordinal))
                        _trackSteering = tr;
                    if (tr.name.StartsWith(sustravName, StringComparison.Ordinal))
                        _susTrav = tr;
                }

                initialPosition = _susTrav.localPosition;
                susTravIndex = KFExtensions.SetAxisIndex(susTravAxis);
                steeringIndex = KFExtensions.SetAxisIndex(steeringAxis);

                if (_KFModuleWheel.hasSteering)
                {
                    initialSteeringAngles = _trackSteering.transform.localEulerAngles;

                    #if DEBUG
                    KFLog.Log(string.Format("initial steering angles are \"{0}\"", initialSteeringAngles));
                    #endif
                }

                directionCorrector = useDirectionCorrector ? _KFModuleWheel.directionCorrector : 1;
                _wheelRotation = new Vector3(wheelRotationX, wheelRotationY, wheelRotationZ);

                if (Equals(lastFrameTraverse, 0)) //check to see if we have a value in persistance
                {
                    #if DEBUG
                    KFLog.Log("Last frame = 0. Setting suspension distance.");
                    #endif

                    lastFrameTraverse = _wheelCollider.suspensionDistance;
                }

                #if DEBUG
                KFLog.Log(string.Format("Last frame = {0}", lastFrameTraverse));
                #endif

                couroutinesActive = true;

                MoveSuspension(susTravIndex, -lastFrameTraverse, _susTrav); //to get the initial stuff correct

                if (_KFModuleWheel.hasSteering)
                {
                    StartCoroutine("Steering");

                    #if DEBUG
                    KFLog.Log("Starting steering coroutine.");
                    #endif
                }
                if (trackedWheel)
                    StartCoroutine("TrackedWheel");
                else
                    StartCoroutine("IndividualWheel");

                if (hasSuspension)
                {
                    KFLog.Warning("KFWheel suspension module is deprecated. Please use KFSuspension.");
                    StartCoroutine("Suspension");
                }
                part.force_activate();
            }
            base.OnStart(state);
        }
Exemplo n.º 41
0
        private void Start()
        {
            car = transform.parent.GetComponent<CarController>();
            wheelCollider = collider as WheelCollider;

            if (wheelModel != null)
            {
                originalWheelModelPosition = wheelModel.localPosition;
                transform.position = wheelModel.position; // - wheelCollider.suspensionDistance*0.5f*transform.up;
            }

            // store initial starting values of wheelCollider
            sidewaysFriction = wheelCollider.sidewaysFriction;
            forwardFriction = wheelCollider.forwardFriction;
            sidewaysStiffness = wheelCollider.sidewaysFriction.stiffness;
            forwardStiffness = wheelCollider.forwardFriction.stiffness;

            // nominal max rpm at Car's top speed (can be more if Car is rolling downhill!)
            MaxRpm = (car.MaxSpeed/(Mathf.PI*wheelCollider.radius*2))*60;

            // get a reference to the particle system for the tire smoke
            skidSmokeSystem = car.GetComponentInChildren<ParticleSystem>();
            rb = wheelCollider.attachedRigidbody;

            if (skidTrailsDetachedParent == null)
            {
                skidTrailsDetachedParent = new GameObject("Skid Trails - Detached").transform;
            }
        }
Exemplo n.º 42
0
 void SetupWheelCollider(WheelCollider col)
 {
     m_colliderFriction.stiffness = 0.0f;
     col.sidewaysFriction = m_colliderFriction;
     col.forwardFriction = m_colliderFriction;
     col.motorTorque = 0.00001f;
 }
Exemplo n.º 43
0
 static public int get_radius(IntPtr l)
 {
     UnityEngine.WheelCollider o = (UnityEngine.WheelCollider)checkSelf(l);
     pushValue(l, o.radius);
     return(1);
 }
Exemplo n.º 44
0
        //OnStart
        public override void OnStart(PartModule.StartState state)
        {
            _KFModuleWheel = part.GetComponentInChildren<KFModuleWheel>();
            tweakScaleCorrector = _KFModuleWheel.tweakScaleCorrector;

            if (!isConfigured)
            {
                foreach (WheelCollider wc in part.GetComponentsInChildren<WheelCollider>())
                {
                    if (wc.name.StartsWith(colliderName, StringComparison.Ordinal))
                    {
                        _wheelCollider = wc;
                        suspensionDistance = wc.suspensionDistance;
                        //KFLog.Error(string.Format("SuspensionDistance is: {0}.", suspensionDistance));
                        isConfigured = true;
                    }
                }
            }
            // disable once RedundantIfElseBlock
            else
            {
                //KFLog.Error("Already configured - skipping.");
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                // Do absolutely nothing!
            }

            if (HighLogic.LoadedSceneIsFlight && !Equals(vessel.vesselType, VesselType.Debris) && vessel.parts.Count > 1)
            {
                GameEvents.onGamePause.Add(new EventVoid.OnEvent(OnPause));
                GameEvents.onGameUnpause.Add(new EventVoid.OnEvent(OnUnPause));
                //find named onjects in part
                foreach (WheelCollider wc in part.GetComponentsInChildren<WheelCollider>())
                {
                    if (wc.name.StartsWith(colliderName, StringComparison.Ordinal))
                        _wheelCollider = wc;
                }
                foreach (Transform tr in part.GetComponentsInChildren<Transform>())
                {
                    if (tr.name.StartsWith(wheelName, StringComparison.Ordinal))
                        _wheel = tr;
                    if (tr.name.StartsWith(steeringName, StringComparison.Ordinal))
                        _trackSteering = tr;
                    if (tr.name.StartsWith(sustravName, StringComparison.Ordinal))
                        _susTrav = tr;
                }
                //end find named objects

                initialPosition = _susTrav.localPosition;
                susTravIndex = Extensions.SetAxisIndex(susTravAxis);
                steeringIndex = Extensions.SetAxisIndex(steeringAxis);

                if (_KFModuleWheel.hasSteering)
                {
                    initialSteeringAngles = _trackSteering.transform.localEulerAngles;
                    //KFLog.Log(initialSteeringAngles);
                }

                // Again, if/else can be made into a single line. - Gaalidas
                directionCorrector = useDirectionCorrector ? _KFModuleWheel.directionCorrector : 1;

                _wheelRotation = new Vector3(wheelRotationX, wheelRotationY, wheelRotationZ);

                if (Equals(lastFrameTraverse, 0)) //check to see if we have a value in persistance
                {
                    //KFLog.Error("Last frame = 0. Setting");
                    lastFrameTraverse = _wheelCollider.suspensionDistance;
                    //KFLog.Error(lastFrameTraverse);
                }
                //KFLog.Error("Last frame =");
                //KFLog.Error(lastFrameTraverse);
                couroutinesActive = true;

                MoveSuspension(susTravIndex, -lastFrameTraverse, _susTrav); //to get the initial stuff correct

                if (_KFModuleWheel.hasSteering)
                {
                    StartCoroutine("Steering");
                    //KFLog.Error("starting steering coroutine");
                }
                if (trackedWheel)
                    StartCoroutine("TrackedWheel");
                else
                    StartCoroutine("IndividualWheel");

                if (hasSuspension)
                {
                    KFLog.Error("WARNING: KFWheel suspension module is deprecated. Please use KFSuspension");
                    StartCoroutine("Suspension");
                }

                part.force_activate();
            }//end flight
            base.OnStart(state);
        }
Exemplo n.º 45
0
        public override void OnStart(PartModule.StartState state)
        {
            GameObject _susTrav = part.FindModelTransform(susTravName).gameObject;
            foreach (var wc in part.GetComponentsInChildren<WheelCollider>())
            {
                if (wc.name.Equals(colliderName, StringComparison.Ordinal))
                    _wheelCollider = wc;
            }

            if (HighLogic.LoadedSceneIsFlight && moveCollider)
            {
                _wheelCollider.transform.Translate(0, moveColliderBy, 0, Space.Self);
                var tempVector = new Vector3(0, 0, 0);
                tempVector[susTravIndex] = moveColliderBy;
                _susTrav.transform.Translate(tempVector, Space.Self);
            }

            if (!Equals(_wheelCollider, null))
            {
                if (!Equals(mass, 0))
                    _wheelCollider.mass = mass;
                if (!Equals(radius, 0))
                    _wheelCollider.radius = radius;
                if (!Equals(suspensionDistance, 0))
                    _wheelCollider.suspensionDistance = suspensionDistance;
                if (!Equals(spring, 0))
                {
                    JointSpring js = _wheelCollider.suspensionSpring;
                    js.spring = spring;
                    _wheelCollider.suspensionSpring = js;
                }
                if (!Equals(damper, 0))
                {
                    JointSpring js = _wheelCollider.suspensionSpring;
                    js.damper = damper;
                    _wheelCollider.suspensionSpring = js;
                }
                if (!Equals(targetPosition, 0))
                {
                    JointSpring js = _wheelCollider.suspensionSpring;
                    js.targetPosition = targetPosition;
                    _wheelCollider.suspensionSpring = js;
                }
                if (overrideFriction)
                {
                    WheelFrictionCurve _forwardFric = _wheelCollider.forwardFriction;
                    _forwardFric.extremumSlip = forExtSlip;
                    _forwardFric.extremumValue = forExtValue;
                    _forwardFric.asymptoteSlip = forAsySlip;
                    _forwardFric.asymptoteValue = forAsyValue;
                    _forwardFric.stiffness = forStiffness;
                    _wheelCollider.forwardFriction = _forwardFric;

                    WheelFrictionCurve _sideFric = _wheelCollider.sidewaysFriction;
                    _sideFric.extremumSlip = forExtSlip;
                    _sideFric.extremumValue = forExtValue;
                    _sideFric.asymptoteSlip = forAsySlip;
                    _sideFric.asymptoteValue = forAsyValue;
                    _sideFric.stiffness = forStiffness;
                    _wheelCollider.sidewaysFriction = _sideFric;
                }
            }
            base.OnStart(state);
        }
Exemplo n.º 46
0
 public WheelFrictionChanger(Wheel w)
 {
     Collider = w.whCollider;
     forwardFriction  = Collider.forwardFriction;
     sidewaysFriction = Collider.sidewaysFriction;
 }
Exemplo n.º 47
0
 static public int get_steerAngle(IntPtr l)
 {
     UnityEngine.WheelCollider o = (UnityEngine.WheelCollider)checkSelf(l);
     pushValue(l, o.steerAngle);
     return(1);
 }
Exemplo n.º 48
0
        private void Start()
        {
            skidParticles = transform.root.GetComponentInChildren<ParticleSystem>();

            if (skidParticles != null)
            {
                skidParticles.Stop();
            }

            m_WheelCollider = GetComponent<WheelCollider>();
            m_AudioSource = GetComponent<AudioSource>();
            PlayingAudio = false;

            if (skidTrailsDetachedParent == null)
            {
                skidTrailsDetachedParent = new GameObject("Skid Trails - Detached").transform;
            }
        }
Exemplo n.º 49
0
        static void AdjustColliderToWheelMesh(WheelCollider wheelCollider, Transform wheelTransform)
        {
            // Adjust position and rotation

            if (wheelTransform == null)
            {
            Debug.LogError(wheelCollider.gameObject.name + ": A Wheel transform is required");
            return;
            }

            wheelCollider.transform.position = wheelTransform.position + wheelTransform.up * wheelCollider.suspensionDistance * 0.5f;
            wheelCollider.transform.rotation = wheelTransform.rotation;

            // Adjust radius

            MeshFilter[] meshFilters = wheelTransform.GetComponentsInChildren<MeshFilter>();
            if (meshFilters == null || meshFilters.Length == 0)
            {
            Debug.LogWarning(wheelTransform.gameObject.name + ": Couldn't calculate radius. There are no meshes in the Wheel transform or its children");
            return;
            }

            // Calculate the bounds of the meshes contained in the Wheel transform

            Bounds bounds = GetScaledBounds(meshFilters[0]);

            for (int i=1, c=meshFilters.Length; i<c; i++)
            {
            Bounds meshBounds = GetScaledBounds(meshFilters[i]);
            bounds.Encapsulate(meshBounds.min);
            bounds.Encapsulate(meshBounds.max);
            }

            // If this is a correct round wheel then extents for y and z should be approximately the same.

            if (Mathf.Abs(bounds.extents.y-bounds.extents.z) > 0.01f)
            Debug.LogWarning(wheelTransform.gameObject.name + ": The Wheel mesh might not be a correct wheel. The calculated radius is different along forward and vertical axis.");

            wheelCollider.radius = bounds.extents.y;
        }
Exemplo n.º 50
0
        void UpdateWheelCollider(WheelCollider col)
        {
            if (!col.enabled) return;

            JointSpring suspension = col.suspensionSpring;
            float sprungForce = -col.sprungMass * Physics.gravity.y;
            float pos = sprungForce / suspension.spring;
            suspension.targetPosition = Mathf.Clamp01(pos / col.suspensionDistance);

            float minSpringRate = sprungForce / col.suspensionDistance;
            float maxSpringRate = sprungForce / (col.suspensionDistance * 0.1f);
            suspension.spring = Mathf.Clamp(suspension.spring, minSpringRate, maxSpringRate);
            col.suspensionSpring = suspension;
        }
Exemplo n.º 51
0
 public override void Reset () {
     wheelCollider = null;
     wheelModel = null;
 }
Exemplo n.º 52
0
 float GetWheelForceDistance(WheelCollider col)
 {
     return m_rigidbody.centerOfMass.y - m_transform.InverseTransformPoint(col.transform.position).y
     + col.radius + (1.0f - col.suspensionSpring.targetPosition) * col.suspensionDistance;
 }