public Brake(WheelLocation location, Range optimumTemperature, Range thicknessStart, float thicknessFailure, float torque) { Location = location; OptimumTemperature = optimumTemperature; ThicknessStart = thicknessStart; ThicknessFailure = thicknessFailure; Torque = torque; }
private Constraint GetOrFindConstraint(WheelLocation location, string postfix, Constraint[] cache) { if (cache[(int)location] == null) { cache[(int)location] = FindChild <Constraint>(location.ToString() + postfix); } return(cache[(int)location]); }
private RigidBody GetOrFindWheel(WheelLocation location) { if (m_wheelBodies[(int)location] == null) { m_wheelBodies[(int)location] = FindChild <RigidBody>(location.ToString() + "Tire"); } return(m_wheelBodies[(int)location]); }
public Wheel(WheelLocation location, float perimeter, float rollResistance, Range peakTemperature, Range pitsTemperature, Range peakPressure) { Location = location; Perimeter = perimeter; RollResistance = rollResistance; PeakTemperature = peakTemperature; PitsTemperature = pitsTemperature; PeakPressure = peakPressure; }
public int GetWheelRpm(WheelLocation wheel) { if (wheel == WheelLocation.Left) { var hallEffectSensorResult = halleffectSensors.Left.GetHallEffectSensorResult(); return((int)(hallEffectSensorResult.DutyCycleA * 1000 * (hallEffectSensorResult.Forward ? 1 : -1))); } else { var hallEffectSensorResult = halleffectSensors.Right.GetHallEffectSensorResult(); return((int)(hallEffectSensorResult.DutyCycleA * 1000 * (hallEffectSensorResult.Forward ? 1 : -1))); } }
public CarTestWheel(WheelLocation location, float perimeter, float rollResistance, Range peakTemperature, Range pitsTemperature, Range peakPressure) : base(location, perimeter, rollResistance, peakTemperature, pitsTemperature, peakPressure) { }
public CarTestBrake(WheelLocation location, Range optimumTemperature, Range thicknessStart, float thicknessFailure, float torque) : base(location, optimumTemperature, thicknessStart, thicknessFailure, torque) { }
private TwoBodyTire GetOrCreateTireModel(WheelLocation location) { if (m_tireModels == null || m_tireModels.Length == 0) { m_tireModels = new TwoBodyTire[4] { null, null, null, null }; var tireModels = GetComponents <TwoBodyTire>(); if (tireModels.Length == 4) { foreach (WheelLocation wl in Enum.GetValues(typeof(WheelLocation))) { var trb = GetOrFindWheel(wl); var rrb = FindChild <RigidBody>(wl.ToString() + "Rim"); m_tireModels[(int)wl] = tireModels.FirstOrDefault(tireModel => tireModel.TireRigidBody == trb && tireModel.RimRigidBody == rrb); } } else if (tireModels.Length != 0) { Debug.LogWarning("Tire models mismatch: Got " + tireModels.Length + ", expecting 0 or 4.", this); } } var iLocation = (int)location; if (m_tireModels[iLocation] != null) { return(m_tireModels[iLocation]); } var tireRigidBody = GetOrFindWheel(location); var rimRigidBody = FindChild <RigidBody>(location.ToString() + "Rim"); if (tireRigidBody == null || rimRigidBody == null) { return(null); } var locks = (from constraint in GetComponentsInChildren <Constraint>() where constraint.Type == ConstraintType.LockJoint select constraint).ToArray(); var tireLock = locks.FirstOrDefault(constraint => constraint.AttachmentPair.Match(tireRigidBody, rimRigidBody)); TwoBodyTire tire = gameObject.AddComponent <TwoBodyTire>(); tire.hideFlags = HideFlags.HideInInspector; bool valid = false; if (tireLock != null) { valid = tire.Configure(tireLock, tireRigidBody); } else { valid = tire.SetTire(tireRigidBody); valid = valid && tire.SetRim(rimRigidBody); } if (!valid) { DestroyImmediate(tire); return(null); } m_tireModels[iLocation] = tire; return(tire); }
public Wheel(GameObject gameObject) { model = gameObject; side = model.name.IndexOf("Left") != -1 ? WheelSide.Left : WheelSide.Right; location = model.name.IndexOf("Front") != -1 ? WheelLocation.Front : WheelLocation.Back; }