// #### UNITY INTERNAL METHODS #### protected void Awake() { wheelCollider = GetComponent <WheelCollider>(); lastFixedUpdateTime = Time.time; skidmarksController = FindObjectOfType <Skidmarks>(); }
private const float BOOST_FOV_DEC = 5 * BOOST_FOV_BASE_CHANGE / 3; // Spend the rest of the time decreasing. // Use this for initialization void Start() { skidmarks = FindObjectOfType <Skidmarks>(); // Create an object with the skidmarks script if no such object exists. if (skidmarks == null) { GameObject skidmarkObject = new GameObject("Skidmark Object"); skidmarks = skidmarkObject.AddComponent <Skidmarks>(); skidmarkObject.GetComponent <MeshRenderer>().material = skidmarkMaterial; } rigidbody.centerOfMass = centerOfMass.localPosition; SetupWheels(); frontAntiRoll.leftWheel = wheels[0].collider; frontAntiRoll.rightWheel = wheels[1].collider; frontAntiRoll.antiRoll = suspensionFrontForce; rearAntiRoll.leftWheel = wheels[2].collider; rearAntiRoll.rightWheel = wheels[3].collider; rearAntiRoll.antiRoll = suspensionRearForce; camera = transform.parent.GetComponentInChildren <Camera>(); }
private void Start() { race = GameObject.Find("Race").GetComponent <Race>(); pModel = PersistentModel.Instance; stop = false; m_Topspeed = m_CurrentTopspeed = 70; m_WheelMeshLocalRotations = new Quaternion[4]; for (int i = 0; i < 4; i++) { m_WheelMeshLocalRotations[i] = m_WheelMeshes[i].transform.localRotation; } m_WheelColliders[0].attachedRigidbody.centerOfMass = m_CentreOfMassOffset; m_MaxHandbrakeTorque = float.MaxValue; m_Rigidbody = GetComponent <Rigidbody>(); m_CurrentTorque = m_FullTorqueOverAllWheels - (m_TractionControl * m_FullTorqueOverAllWheels); this.skidMarksController = GameObject.Find("SkidMarksController").GetComponent <Skidmarks>(); // right m_WheelColliders[2].gameObject.GetComponent <WheelSkid>().rb = m_Rigidbody; m_WheelColliders[2].gameObject.GetComponent <WheelSkid>().skidmarksController = this.skidMarksController; // left wheel m_WheelColliders[3].gameObject.GetComponent <WheelSkid>().rb = m_Rigidbody; m_WheelColliders[3].gameObject.GetComponent <WheelSkid>().skidmarksController = this.skidMarksController; }
private void Start() { if (skidmarksController == null) { skidmarksController = GameObject.FindGameObjectWithTag("Skidmark").GetComponent <Skidmarks>(); } }
// #### UNITY INTERNAL METHODS #### protected void Awake() { Instance = this; if (transform.position != Vector3.zero) { Debug.LogWarning("Skidmarks.cs transform must be at 0,0,0. Setting it to zero now."); transform.position = Vector3.zero; transform.rotation = Quaternion.identity; } }
// #### UNITY INTERNAL METHODS #### protected void Awake() { wheelCollider = GetComponent <WheelCollider>(); lastFixedUpdateTime = Time.time; Controller = GetComponentInParent <VehicleController>(); if (!skidmarksController) { skidmarksController = FindObjectOfType <Skidmarks>(); } }
static public int get_GROUND_OFFSET(IntPtr l) { try { Skidmarks self = (Skidmarks)checkSelf(l); pushValue(l, self.GROUND_OFFSET); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_MARK_WIDTH(IntPtr l) { try { Skidmarks self = (Skidmarks)checkSelf(l); pushValue(l, self.MARK_WIDTH); return(1); } catch (Exception e) { return(error(l, e)); } }
void Start() { myCrawlerMat = new Material(crawlerMat); leftCrawler = crawler.FindChild("LeftCrawler").renderer; rightCrawler = crawler.FindChild("RightCrawler").renderer; leftCrawlerMat = new Material(crawlerMat); rightCrawlerMat = new Material(crawlerMat); leftCrawler.sharedMaterial = leftCrawlerMat; rightCrawler.sharedMaterial = rightCrawlerMat; skidObj = (GameObject)GameObject.Instantiate(skidMarkPref, Vector3.zero, Quaternion.identity); skid = skidObj.GetComponent <Skidmarks>(); }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
static public int set_MARK_WIDTH(IntPtr l) { try { Skidmarks self = (Skidmarks)checkSelf(l); System.Single v; checkType(l, 2, out v); self.MARK_WIDTH = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_GROUND_OFFSET(IntPtr l) { try { Skidmarks self = (Skidmarks)checkSelf(l); System.Single v; checkType(l, 2, out v); self.GROUND_OFFSET = v; return(0); } catch (Exception e) { return(error(l, e)); } }
// Start is called before the first frame update void Start() { GameObject skidObj = new GameObject("Skidmarks"); skidmarksController = skidObj.AddComponent <Skidmarks>(); skidmarksController.skidmarksMaterial = skidMaterial; if (skidmarksController == null) { Debug.LogError("No Skidmarks found in scene"); } wheel = GetComponent <WheelColliderAdv>().CWWheel; }
// Use this for initialization void Start() { Physics.gravity = new Vector3(0.0f, -20.81f, 0.0f); //Get all the transforms in the scene Transform[] tms = FindObjectsOfType <Transform>(); //we will count the tranforms that have the word "ramp" in their name int rampCount = 0; for (int i = 0; i < tms.Length; i++) { if (tms[i].name.ToLower().Contains("ramp")) { rampCount += 1; } } //create a new array of ramps ramps = new Transform[rampCount]; //go back through the list and set each ramp in our ramp array rampCount = 0; for (int i = 0; i < tms.Length; i++) { if (tms[i].name.ToLower().Contains("ramp")) { ramps[rampCount] = tms[i]; rampCount += 1; } } lastTime = Time.fixedTime; lastPosition = transform.position; body.centerOfMass = centerOfMass; GameObject go = GameObject.Find("Skidmarks"); Skidmarks skid = go.GetComponent <Skidmarks>(); for (int i = 0; i < wheels.Length; i++) { wheels[i].lastPosition = wheels[i].collider.transform.position; wheels[i].lastSkid = -1; if (skid != null) { wheels[i].skidmark = skid; } } rampWheel.SetActive(true); rampWheel.SetActive(false); }
public void StartCar() { skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks)); wheels = new WheelData[4]; for (int i = 0; i < 4; i++) { wheels[i] = new WheelData(); } wheels[0].graphic = wheelFL; wheels[1].graphic = wheelFR; wheels[2].graphic = wheelBL; wheels[3].graphic = wheelBR; wheels[0].maxSteerAngle = 30.0f; wheels[1].maxSteerAngle = 30.0f; wheels[2].powered = true; wheels[3].powered = true; wheels[2].handbraked = true; wheels[3].handbraked = true; foreach (WheelData w in wheels) { if (w.graphic == null) { Debug.Log("You need to assign all four wheels for the car script!"); } if (!w.graphic.transform.IsChildOf(transform)) { Debug.Log("Wheels need to be children of the Object with the car script"); } w.originalRotation = w.graphic.localRotation; GameObject colliderObject = new GameObject("WheelCollider"); colliderObject.transform.parent = transform; colliderObject.transform.position = w.graphic.position; w.coll = (WheelCollider)colliderObject.AddComponent(typeof(WheelCollider)); w.coll.suspensionDistance = suspensionDistance; JointSpring t = new JointSpring(); t.spring = springs; t.damper = dampers; w.coll.suspensionSpring = t; WheelFrictionCurve wf = new WheelFrictionCurve(); wf.stiffness = wf.extremumValue = wf.extremumSlip = wf.asymptoteSlip = wf.asymptoteValue = 6; w.coll.forwardFriction = wf; w.coll.sidewaysFriction = wf; w.coll.radius = wheelRadius; } wheelY = wheels[0].graphic.localPosition.y; gear = 1; }
private WheelCollider wheel_col; //To hold self wheel collider void Start() { //Get the Wheel Collider attached to self skidCaller = transform.root.gameObject; wheel_col = GetComponent <WheelCollider>(); //find object "Skidmarks" from the game if (FindObjectOfType(typeof(Skidmarks))) { skidmarks = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; } else { Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); } }
void Start() { Transform trs = transform; while (trs != null && trs.rigidbody == null) { trs = trs.parent; } if (trs != null) { body = trs.rigidbody; } InitSlipMaxima(); skid = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; fullCompressionSpringForce = body.mass * massFraction * 2.0f * -Physics.gravity.y; }
// #### UNITY INTERNAL METHODS #### protected void Start() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); this.transform.position = new Vector3(0, 0, 0); // Generate a fixed array of skidmarks skidmarks = new MarkSection[MAX_MARKS]; for (int i = 0; i < MAX_MARKS; i++) { skidmarks[i] = new MarkSection(); } mf = GetComponent <MeshFilter>(); mr = GetComponent <MeshRenderer>(); if (mr == null) { mr = gameObject.AddComponent <MeshRenderer>(); } marksMesh = new Mesh(); marksMesh.MarkDynamic(); if (mf == null) { mf = gameObject.AddComponent <MeshFilter>(); } mf.sharedMesh = marksMesh; vertices = new Vector3[MAX_MARKS * 4]; normals = new Vector3[MAX_MARKS * 4]; tangents = new Vector4[MAX_MARKS * 4]; colors = new Color32[MAX_MARKS * 4]; uvs = new Vector2[MAX_MARKS * 4]; triangles = new int[MAX_MARKS * 6]; mr.shadowCastingMode = ShadowCastingMode.Off; mr.receiveShadows = false; mr.material = skidmarksMaterial; mr.lightProbeUsage = LightProbeUsage.Off; }
void SetUpSkidmarks() { if (FindObjectOfType(typeof(Skidmarks))) { skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks)); skidSmoke = skidmarks.GetComponentInChildren <ParticleEmitter>(); } else { Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); } skidmarkTime = new float[4]; for (int i = 0; i < 4; i++) { skidmarkTime[i] = 0.0f; } }
private WheelCollider wheel_col; //To hold self wheel collider void Start() { Debug.LogWarning("Wheel Skidmarks has not been ported to the new PhysX system"); return; //Get the Wheel Collider attached to self skidCaller = transform.root.gameObject; wheel_col = GetComponent <WheelCollider>(); //find object "Skidmarks" from the game if (FindObjectOfType <Skidmarks>()) { skidmarks = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; } else { Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); } }
public float markWidth = 0.275f; // The width of the skidmarks. Should match the width of the wheel that it is used for. In meters. void Start() { if (!carParent) { carParent = GetComponentInParent <Rigidbody> (); } wheel_col = GetComponent <WheelCollider> (); if (FindObjectOfType <Skidmarks>()) { skidmarks = FindObjectOfType <Skidmarks>(); } else { Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); } }
public void StartCar() { skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks)); wheels = new WheelData[4]; for (int i = 0; i < 4; i++) wheels[i] = new WheelData(); wheels[0].graphic = wheelFL; wheels[1].graphic = wheelFR; wheels[2].graphic = wheelBL; wheels[3].graphic = wheelBR; wheels[0].maxSteerAngle = 30.0f; wheels[1].maxSteerAngle = 30.0f; wheels[2].powered = true; wheels[3].powered = true; wheels[2].handbraked = true; wheels[3].handbraked = true; foreach (WheelData w in wheels) { if (w.graphic == null) Debug.Log("You need to assign all four wheels for the car script!"); if (!w.graphic.transform.IsChildOf(transform)) Debug.Log("Wheels need to be children of the Object with the car script"); w.originalRotation = w.graphic.localRotation; GameObject colliderObject = new GameObject("WheelCollider"); colliderObject.transform.parent = transform; colliderObject.transform.position = w.graphic.position; w.coll = (WheelCollider)colliderObject.AddComponent(typeof(WheelCollider)); w.coll.suspensionDistance = suspensionDistance; JointSpring t = new JointSpring(); t.spring = springs; t.damper = dampers; w.coll.suspensionSpring = t; WheelFrictionCurve wf = new WheelFrictionCurve(); wf.stiffness = wf.extremumValue = wf.extremumSlip = wf.asymptoteSlip = wf.asymptoteValue = 6; w.coll.forwardFriction = wf; w.coll.sidewaysFriction = wf; w.coll.radius = wheelRadius; } wheelY = wheels[0].graphic.localPosition.y; gear = 1; }
static public int AddSkidMark(IntPtr l) { try { Skidmarks self = (Skidmarks)checkSelf(l); UnityEngine.Vector3 a1; checkType(l, 2, out a1); UnityEngine.Vector3 a2; checkType(l, 3, out a2); System.Single a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); var ret = self.AddSkidMark(a1, a2, a3, a4); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
public void Awake() { print("Game Awake"); InitValues(); enabled = _Loader.menuLoaded; //if (!online || PhotonNetwork.room != null) // OnJoinedRoom(); bounds = GetLevelBounds(); skidmarks = GetComponentInChildren <Skidmarks>(); m_skidSmoke = skidmarks.GetComponentInChildren <ParticleEmitter>(); if (!_Loader.menuLoaded) { hostRoom = new Room("", null); room.gameType = settings.gameType; _Loader.Connect(); } else { Destroy(GameObject.Find("_test")); } Awake3(); }
// Use this for initialization void Awake() { skidMark = GameObject.Find("Skidmarks").transform; skid = skidMark.GetComponent <Skidmarks>(); myCrawlerMat = new Material(crawlerMat); leftCrawler.sharedMaterial = myCrawlerMat; rightCrawler.sharedMaterial = myCrawlerMat; // if(!networkView.isMine) return; // Rigidbody rb = gameObject.AddComponent<Rigidbody>(); // rb.mass = mass; // rb.drag = 0.0f; // rb.angularDrag = 0.0f; // rb.useGravity = true; // rb.isKinematic = false; rigidbody.centerOfMass = CoM.localPosition; JointSpring js; wheelCollider = new WheelCollider[WHEEL_COUNT]; for (int i = 0; i < WHEEL_COUNT; i++) { wheelCollider[i] = wheelColliderObject[i].gameObject.AddComponent <WheelCollider>(); wheelCollider[i].mass = wheelMass; wheelCollider[i].radius = wheelRadius; wheelCollider[i].suspensionDistance = wheelSuspensionDistance; js = new JointSpring(); js.spring = wheelSpring; js.damper = wheelDamper; js.targetPosition = wheelTargetPosition; wheelCollider[i].suspensionSpring = js; wheelCollider[i].brakeTorque = Mathf.Infinity; } // head.GetComponent<MyTankHeadBehaviour>().mTank = rb; // GlobalInfo.playerViewID = networkView.viewID; Camera.main.gameObject.GetComponent <AudioListener>().enabled = true; // Screen.lockCursor = true; }
void Start() { Instance = this; if (transform.position != Vector3.zero) { transform.position = Vector3.zero; } #if ClientCode skidmarks = new markSection[maxMarks]; for (int i = 0; i < maxMarks; i++) { skidmarks[i] = new markSection(); } mesh = GetComponent <MeshFilter>().mesh; if (mesh == null) { GetComponent <MeshFilter>().mesh = new Mesh(); } #endif }
void Start() { Transform trs = transform; while (trs != null && trs.GetComponent<Rigidbody>() == null) trs = trs.parent; if (trs != null) body = trs.GetComponent<Rigidbody>(); InitSlipMaxima (); skid = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; skidSmoke = GetComponentsInChildren<ParticleSystem>(); fullCompressionSpringForce = body.mass * massFraction * 2.0f * -Physics.gravity.y; }
void Start () { Transform trs = transform; while (trs != null && trs.rigidbody == null) trs = trs.parent; if (trs != null) body = trs.rigidbody; InitSlipMaxima (); skid = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; fullCompressionSpringForce = body.mass * massFraction * 2.0f * -Physics.gravity.y; }
void Start(){ myTransform=transform; trs = myTransform.parent; while (trs != null && trs.rigidbody == null) trs = trs.parent; if (trs != null) body = trs.rigidbody; trs = myTransform.parent; while (trs.GetComponent<PhysicMaterials>() == null) {if (trs.parent) trs = trs.parent; else break;} physicMaterials = trs.GetComponent<PhysicMaterials>(); trs = myTransform.parent; while (trs.GetComponent<CarDynamics>() == null) trs = trs.parent; cardynamics = trs.GetComponent<CarDynamics>(); drivetrain = trs.GetComponent<Drivetrain>(); axles = trs.GetComponent<Axles>(); localScale=1/(trs.localScale.y*myTransform.localScale.y); layerMask=1<<trs.gameObject.layer | 1<<myTransform.gameObject.layer;//LayerMask.NameToLayer("Wheel"); layerMask=~layerMask; radiusLoaded=radius; if (rimRadius==0) rimRadius=radius*0.735f; sidewallHeight=radius - rimRadius; if (mass<50*cardynamics.invFixedTimeStepScalar) mass=50*cardynamics.invFixedTimeStepScalar; if (rotationalInertia==0 || rotationalInertia<(mass/2)*radius*radius) rotationalInertia=(mass/2)*radius*radius; originalMass=mass; if (model==null) { model = new GameObject("temp_model"); model.transform.parent=transform; model.transform.localPosition=new Vector3(0,0,0); model.transform.localRotation=Quaternion.identity; Debug.LogWarning("UnityCar: wheel model in " + wheelPos + " is missing. Using empty object" + " (" +trs.name+ ")"); } modelTransform=model.transform; if (caliperModel!=null) caliperModelTransform=caliperModel.transform; skidmarks = cardynamics.skidmarks; if (skidmarks) skidSmoke = skidmarks.GetComponentInChildren(typeof(ParticleEmitter)) as ParticleEmitter; suspensionLineRenderer=gameObject.GetComponent<LineRenderer>(); if (suspensionLineRenderer==null) suspensionLineRenderer = gameObject.AddComponent<LineRenderer>(); suspensionLineRenderer.material = new Material(Shader.Find("Diffuse")); suspensionLineRenderer.material.color = Color.yellow; suspensionLineRenderer.SetWidth(0.01f,0.1f); suspensionLineRenderer.useWorldSpace = false; suspensionLineRenderer.castShadows = false; camber*=1; // to avoid never assigned warning if (camber==0){ up = myTransform.up; } else{ camberRotation = Quaternion.AngleAxis(-camber,forwardNormal); up = camberRotation*myTransform.up; } SetTireStiffness(); }
public void Awake() { print("Game Awake"); InitValues(); enabled = _Loader.menuLoaded; //if (!online || PhotonNetwork.room != null) // OnJoinedRoom(); bounds = GetLevelBounds(); skidmarks = GetComponentInChildren<Skidmarks>(); m_skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>(); if (!_Loader.menuLoaded) { hostRoom = new Room("", null); room.gameType = settings.gameType; _Loader.Connect(); } else Destroy(GameObject.Find("_test")); Awake3(); }
// Start is called before the first frame update void Start() { skidMarkController = FindObjectOfType <Skidmarks>(); playerCar = GetComponentInParent <PlayerCar>(); particleSystem = GetComponentInParent <ParticleSystem>(); }
void Start() { //Destroy existing rigidbody, we don't want anyone to mess with it. if(rigidbody) Destroy(rigidbody); //setup rigidbody gameObject.AddComponent<Rigidbody>(); rigidbody.mass = mass; rigidbody.drag = drag; rigidbody.angularDrag = 0.05f; rigidbody.centerOfMass = new Vector3(rigidbody.centerOfMass.x, cogY, rigidbody.centerOfMass.z); rigidbody.interpolation = RigidbodyInterpolation.Interpolate; // rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ; //start engine noise audio.loop = true; audio.Play(); SMCamera = Camera.main.GetComponent<SmoothFollow>(); //setup wheels wheels=new WheelData[4 + otherWheels.Length]; for(int i=0;i<4 + otherWheels.Length;i++) wheels[i] = new WheelData(); wheels[0].graphic = wheelFL; wheels[1].graphic = wheelFR; wheels[2].graphic = wheelBL; wheels[3].graphic = wheelBR; for(int i=0;i < otherWheels.Length;i++) { wheels[i + 4].graphic = otherWheels[i]; } wheels[0].maxSteerAngle = 30.0f; wheels[1].maxSteerAngle = 30.0f; wheels[2].powered = true; wheels[3].powered = true; wheels[2].handbraked = true; wheels[3].handbraked = true; foreach(WheelData w in wheels) { if(w.graphic == null) Debug.Log("You need to assign all four wheels for the car script!"); if(!w.graphic.transform.IsChildOf(transform)) Debug.Log("Wheels need to be children of the Object with the car script"); w.originalRotation = w.graphic.localRotation; //create collider GameObject colliderObject = new GameObject("WheelCollider"); colliderObject.transform.parent = transform; colliderObject.transform.localPosition = w.graphic.localPosition; colliderObject.transform.localRotation = w.graphic.localRotation; w.coll = colliderObject.AddComponent<WheelCollider>(); w.coll.suspensionDistance = suspensionDistance; JointSpring js = new JointSpring(); js.spring = springs; js.damper = dampers; // w.coll.suspensionSpring.spring = springs; // w.coll.suspensionSpring.damper = dampers; w.coll.suspensionSpring = js; //no grip, as we simulate handling ourselves WheelFrictionCurve forwardwfc = new WheelFrictionCurve(); forwardwfc.stiffness = 0; WheelFrictionCurve sidewaywfc = new WheelFrictionCurve(); sidewaywfc.stiffness = 0; // w.coll.forwardFriction.stiffness = 0; // w.coll.sidewaysFriction.stiffness = 0; w.coll.forwardFriction = forwardwfc; w.coll.sidewaysFriction = sidewaywfc; w.coll.radius = wheelRadius; } //get wheel height (height forces are applied on) // wheelY = wheels[0].graphic.localPosition.y; //find skidmark object skidmarks = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; //shift to first gear = 1; defaultMaxRPM = maxRPM; defaultMaxTorque = maxTorque; carAI = GetComponent<CarAI>(); }
public void Awake() { skidmarksController = GameObject.Find("skid_marks(Clone)").GetComponent <Skidmarks>(); }
protected void Start() { skidmarksController = Skidmarks.Instance; }
void Start() { myTransform = transform; trs = myTransform.parent; //while (trs != null && trs.rigidbody == null) trs = trs.parent; //if (trs != null) body = trs.rigidbody; //Rigidbody rb = trs.GetComponent<Rigidbody>(); //while (trs != null && trs.gameObject.GetComponent<Rigidbody>() == null) trs = trs.parent; //if (trs != null) body = trs.gameObject.GetComponent<Rigidbody>(); if (body == null) { Rigidbody rb; do { rb = trs.GetComponent <Rigidbody>(); trs = trs.parent; }while (trs != null && rb == null); if (trs != null) { body = rb; } } //if (!trs.TryGetComponent<Rigidbody>(out body)) trs = trs.parent; trs = myTransform.parent; while (trs.GetComponent <PhysicMaterials>() == null) { if (trs.parent) { trs = trs.parent; } else { break; } } physicMaterials = trs.GetComponent <PhysicMaterials>(); trs = myTransform.parent; while (trs.GetComponent <CarDynamics>() == null) { trs = trs.parent; } cardynamics = trs.GetComponent <CarDynamics>(); drivetrain = trs.GetComponent <Drivetrain>(); axles = trs.GetComponent <Axles>(); localScale = 1 / (trs.localScale.y * myTransform.localScale.y); layerMask = 1 << trs.gameObject.layer | 1 << myTransform.gameObject.layer; //LayerMask.NameToLayer("Wheel"); layerMask = ~layerMask; radiusLoaded = radius; if (rimRadius == 0) { rimRadius = radius * 0.735f; } sidewallHeight = radius - rimRadius; if (mass < 50 * cardynamics.invFixedTimeStepScalar) { mass = 50 * cardynamics.invFixedTimeStepScalar; } if (rotationalInertia == 0 || rotationalInertia < (mass / 2) * radius * radius) { rotationalInertia = (mass / 2) * radius * radius; } originalMass = mass; if (model == null) { model = new GameObject("temp_model"); model.transform.parent = transform; model.transform.localPosition = new Vector3(0, 0, 0); model.transform.localRotation = Quaternion.identity; Debug.LogWarning("UnityCar: wheel model in " + wheelPos + " is missing. Using empty object" + " (" + trs.name + ")"); } modelTransform = model.transform; if (caliperModel != null) { caliperModelTransform = caliperModel.transform; } skidmarks = cardynamics.skidmarks; //if (skidmarks) skidSmoke = skidmarks.GetComponentInChildren(typeof(ParticleEmitter)) as ParticleEmitter; //suspensionLineRenderer=gameObject.GetComponent<LineRenderer>(); //if (suspensionLineRenderer==null) suspensionLineRenderer = gameObject.AddComponent<LineRenderer>(); //suspensionLineRenderer.material = new Material(Shader.Find("Diffuse")); //suspensionLineRenderer.material.color = Color.yellow; //suspensionLineRenderer.SetWidth(0.01f,0.1f); //suspensionLineRenderer.useWorldSpace = false; //suspensionLineRenderer.castShadows = false; camber *= 1; // to avoid never assigned warning if (camber == 0) { up = myTransform.up; } else { camberRotation = Quaternion.AngleAxis(-camber, forwardNormal); up = camberRotation * myTransform.up; } SetTireStiffness(); }
protected void SetUpSkidmarks() { if(FindObjectOfType(typeof(Skidmarks))) { skidmarks = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>(); } else //Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); skidmarkTime = new float[4]; //foreach(float f in skidmarkTime) // f = 0.0f; }
// Use this for initialization void Start() { DontDestroyOnLoad(gameObject); if (!networkView.isMine) { enabled = false; return; } skidMark = GameObject.Find("Skidmarks").transform; skid = skidMark.GetComponent <Skidmarks>(); Rigidbody rb = gameObject.AddComponent <Rigidbody>(); rb.mass = mass; rb.drag = 0.0f; rb.angularDrag = 0.0f; if (isKinamatics) { rb.useGravity = false; rb.isKinematic = true; } else { rb.useGravity = true; rb.isKinematic = false; } rigidbody.centerOfMass = CoM.localPosition; ConstantForce cf = gameObject.AddComponent <ConstantForce> (); cf.force = new Vector3(0.0f, -100000.0f, 0.0f); JointSpring js; wheelCollider = new WheelCollider[wheelCount]; for (int i = 0; i < wheelCount; i++) { wheelCollider[i] = wheelColliderObject[i].gameObject.AddComponent <WheelCollider>(); wheelCollider[i].mass = wheelMass; wheelCollider[i].radius = wheelRadius; wheelCollider[i].suspensionDistance = wheelSuspensionDistance; js = new JointSpring(); js.spring = wheelSpring; js.damper = wheelDamper; js.targetPosition = wheelTargetPosition; wheelCollider[i].suspensionSpring = js; wheelCollider[i].brakeTorque = Mathf.Infinity; } head.GetComponent <MyTankHeadBehaviour>().mTank = rb; leftCrawlerMat = new Material(crawlerMat); leftCrawler.sharedMaterial = leftCrawlerMat; rightCrawlerMat = new Material(crawlerMat); rightCrawler.sharedMaterial = rightCrawlerMat; halfWheelCount = wheelCount / 2; if (GlobalInfo.nightOrNoonFlag == 1) { lightUpFlag = false; lighter.SetActive(false); } else if (GlobalInfo.nightOrNoonFlag == 0) { lightUpFlag = true; lighter.SetActive(true); } }
void SetUpSkidmarks() { if(FindObjectOfType(typeof(Skidmarks))) { skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks)); skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>(); } else Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); skidmarkTime = new float[4]; for(int i = 0 ; i < 4 ; i++){ skidmarkTime[i] = 0.0f; } }
void SetUpSkidmarks() { // if(FindObjectOfType(typeof(Skidmarks))) // { // skidmarks = (Skidmarks)FindObjectOfType(typeof(Skidmarks)); // //skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter>(); // skidSmoke = GameObject.Find("WheelSmoke").GetComponentInChildren<ParticleEmitter>(); // } // else // Debug.Log("No skidmarks object found. Skidmarks will not be drawn"); skidmarks = FindObjectOfType(typeof(Skidmarks)) as Skidmarks; skidSmoke = transform.Find("WheelSmoke").GetComponent<ParticleEmitter>(); skidmarkTime = new float[wheels.Length]; for(int i = 0 ; i < skidmarkTime.Length ; i++){ skidmarkTime[i] = 0.0f; } }
void SetUpSkidmarks() { if (FindObjectOfType (typeof(Skidmarks))) { skidmarks = FindObjectOfType (typeof(Skidmarks)) as Skidmarks; skidSmoke = skidmarks.GetComponentInChildren<ParticleEmitter> (); } else Debug.Log ("No skidmarks object found. Skidmarks will not be drawn"); skidmarkTime = new float[4] { 0.0f, 0.0f, 0.0f, 0.0f }; }