public virtual void Start() { vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(transform); vp.trans = this; targetDrive = GetComponent <DriveForce>(); newDrive = gameObject.AddComponent <DriveForce>(); }
public virtual void Start() { vp = transform.root.GetComponent<VehicleParent>(); //Get engine sound snd = GetComponent<AudioSource>(); if (snd) { snd.pitch = minPitch; } //Get boost sound if (boostLoopSnd) { GameObject newBoost = Instantiate(boostLoopSnd.gameObject, boostLoopSnd.transform.position, boostLoopSnd.transform.rotation) as GameObject; boostSnd = newBoost.GetComponent<AudioSource>(); boostSnd.transform.parent = boostLoopSnd.transform; boostSnd.transform.localPosition = Vector3.zero; boostSnd.transform.localRotation = Quaternion.identity; boostSnd.loop = false; } if (smoke) { initialSmokeEmission = smoke.emissionRate; } }
public void ToggleVehicle(VehicleParent newVP) { if (newVP == null) { vp.driverSeat.ToggleDriverMesh(false); vp.ExitVehicle(); cam.target = playerController.transform; UnsmurfPlayer(); cam.vel = tpRagdoll.mainRB; cam.followVel = true; vp = null; inVehicle = false; LeanTween.move(vehicleUI, vehicleUIrestpos, 0.1f); LeanTween.move(inventoryAmmoUI, inventoryAmmoUIactivepos, 0.1f); } else { vp = newVP; vp.driverSeat.ToggleDriverMesh(true, playerMesh.material.mainTexture); vp.EnterVehicle(); SmurfPlayer(vp.driverSeat.transform.position); gearbox = vp.gameObject.GetComponentInChildren <GearboxTransmission>(); engine = vp.gameObject.GetComponentInChildren <Motor>(); trans = vp.gameObject.GetComponentInChildren <Transmission>(); // trans.automatic = autoShiftToggle.isOn; cam.target = vp.gameObject.transform; cam.vel = vp.rb; cam.followVel = true; inVehicle = true; LeanTween.move(vehicleUI, vehicleUIactivepos, 0.1f); LeanTween.move(inventoryAmmoUI, inventoryAmmoUIrestpos, 0.1f); } }
void Start() { tr = transform; rb = GetComponent<Rigidbody>(); vp = GetComponent<VehicleParent>(); initialAngularDrag = rb.angularDrag; }
public virtual void Start() { vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(transform); //Get engine sound snd = GetComponent <AudioSource>(); if (snd) { snd.pitch = minPitch; } //Get boost sound if (boostLoopSnd) { GameObject newBoost = Instantiate(boostLoopSnd.gameObject, boostLoopSnd.transform.position, boostLoopSnd.transform.rotation) as GameObject; boostSnd = newBoost.GetComponent <AudioSource>(); boostSnd.transform.parent = boostLoopSnd.transform; boostSnd.transform.localPosition = Vector3.zero; boostSnd.transform.localRotation = Quaternion.identity; boostSnd.loop = false; } if (smoke) { initialSmokeEmission = smoke.emission.rateOverTime.constantMax; } }
public virtual void Start() { vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(transform); foreach (ParticleSystem curBoost in boostParticles) { curBoost.Stop(); } //Get engine sound snd = GetComponent <AudioSource>(); if (snd) { snd.pitch = minPitch; } //Get boost sound if (boostLoopSnd) { GameObject newBoost = Instantiate(boostLoopSnd.gameObject, boostLoopSnd.transform.position, boostLoopSnd.transform.rotation) as GameObject; boostSnd = newBoost.GetComponent <AudioSource>(); boostSnd.transform.parent = boostLoopSnd.transform; boostSnd.transform.localPosition = Vector3.zero; boostSnd.transform.localRotation = Quaternion.identity; boostSnd.loop = false; } }
public virtual void Start() { this.vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(this.transform); //Get engine sound this.snd = this.GetComponent <AudioSource>(); if (this.snd) { this.snd.pitch = this.minPitch; } //Get boost sound if (this.boostLoopSnd) { var newBoost = Instantiate(this.boostLoopSnd.gameObject, this.boostLoopSnd.transform.position, this.boostLoopSnd.transform.rotation); this.boostSnd = newBoost.GetComponent <AudioSource>(); this.boostSnd.transform.parent = this.boostLoopSnd.transform; this.boostSnd.transform.localPosition = Vector3.zero; this.boostSnd.transform.localRotation = Quaternion.identity; this.boostSnd.loop = false; } if (this.smoke) { this.initialSmokeEmission = this.smoke.emission.rateOverTime.constantMax; } }
void Start() { tr = transform; rb = GetComponent <Rigidbody>(); vp = GetComponent <VehicleParent>(); initialAngularDrag = rb.angularDrag; }
void Start() { agent = GetComponentInChildren<NavMeshAgent> (); VP = GetComponentInParent<VehicleParent> ();//берем контроллер rigBody = GetComponent<Rigidbody> (); currentSteer = 0; }
void Start() { tr = transform; rb = GetComponent <Rigidbody>(); vp = GetComponent <VehicleParent>(); va = GetComponent <VehicleAssist>(); vd = GetComponent <VehicleDamage>(); initialSpeed = speed; }
// Use this for initialization void Start () { MinVel = -2f; Count = this; granos = 0; SetCountText (); Turbo = false; PPgranos=PlayerPrefs.GetInt("Granos"); vp = GetComponent<VehicleParent>(); }
void Start() { tr = transform; rb = GetComponent <Rigidbody>(); vp = GetComponent <VehicleParent>(); va = GetComponent <VehicleAssist>(); initialSpeed = speed; InitializeTarget(); }
void Start() { this.tr = this.transform; this.rb = this.GetComponent <Rigidbody>(); this.vp = this.GetComponent <VehicleParent>(); this.va = this.GetComponent <VehicleAssist>(); this.initialSpeed = this.speed; this.InitializeTarget(); }
void Start() { tr = transform; rb = GetComponent<Rigidbody>(); vp = GetComponent<VehicleParent>(); va = GetComponent<VehicleAssist>(); initialSpeed = speed; InitializeTarget(); }
public virtual void Start() { vp = (VehicleParent)F.GetTopmostParentComponent<VehicleParent>(transform); targetDrive = GetComponent<DriveForce>(); newDrive = gameObject.AddComponent<DriveForce>(); if (legacyTorqueMultiplier) { Debug.LogWarning("Legacy torque multiplier is obsolete and will be removed in a future update.", this); } }
public void SpawnVehicle(int vehicle) { this.newVehicle = Instantiate(this.vehicles[vehicle], this.spawnPoint, Quaternion.LookRotation(this.spawnRot, GlobalControl.worldUpDir)); this.cam.target = this.newVehicle.transform; this.cam.Initialize(); this.vp = this.newVehicle.GetComponent <VehicleParent>(); this.trans = this.newVehicle.GetComponentInChildren <Transmission>(); if (this.trans) { this.trans.automatic = this.autoShift; this.newVehicle.GetComponent <VehicleParent>().brakeIsReverse = this.autoShift; if (this.trans is GearboxTransmission) { this.gearbox = this.trans as GearboxTransmission; } else if (this.trans is ContinuousTransmission) { this.varTrans = this.trans as ContinuousTransmission; if (!this.autoShift) { this.vp.brakeIsReverse = true; } } } if (this.newVehicle.GetComponent <VehicleAssist>()) { this.newVehicle.GetComponent <VehicleAssist>().enabled = this.assist; } if (this.newVehicle.GetComponent <FlipControl>() && this.newVehicle.GetComponent <StuntDetect>()) { this.newVehicle.GetComponent <FlipControl>().flipPower = this.stuntMode && this.assist ? new Vector3(10, 10, -10) : Vector3.zero; this.newVehicle.GetComponent <FlipControl>().rotationCorrection = this.stuntMode ? Vector3.zero : (this.assist ? new Vector3(5, 1, 10) : Vector3.zero); this.newVehicle.GetComponent <FlipControl>().stopFlip = this.assist; this.stunter = this.newVehicle.GetComponent <StuntDetect>(); } this.engine = this.newVehicle.GetComponentInChildren <Motor>(); this.propertySetter = this.newVehicle.GetComponent <PropertyToggleSetter>(); this.stuntText.gameObject.SetActive(this.stuntMode); this.scoreText.gameObject.SetActive(this.stuntMode); }
public void SpawnVehicle(int vehicle) { newVehicle = Instantiate(vehicles[vehicle], spawnPoint, Quaternion.LookRotation(spawnRot, GlobalControl.worldUpDir)) as GameObject; cam.target = newVehicle.transform; cam.Initialize(); vp = newVehicle.GetComponent<VehicleParent>(); cam.GetComponent<CameraControlls>().cameraTarget = newVehicle.transform; trans = newVehicle.GetComponentInChildren<Transmission>(); if (trans) { trans.automatic = autoShift; newVehicle.GetComponent<VehicleParent>().brakeIsReverse = autoShift; if (trans is GearboxTransmission) { gearbox = trans as GearboxTransmission; } else if (trans is ContinuousTransmission) { varTrans = trans as ContinuousTransmission; if (!autoShift) { vp.brakeIsReverse = true; } } } if (newVehicle.GetComponent<VehicleAssist>()) { newVehicle.GetComponent<VehicleAssist>().enabled = assist; } if (newVehicle.GetComponent<FlipControl>() && newVehicle.GetComponent<StuntDetect>()) { newVehicle.GetComponent<FlipControl>().flipPower = stuntMode && assist ? new Vector3(10, 10, -10) : Vector3.zero; newVehicle.GetComponent<FlipControl>().rotationCorrection = stuntMode ? Vector3.zero : (assist ? new Vector3(5, 1, 10) : Vector3.zero); newVehicle.GetComponent<FlipControl>().stopFlip = assist; stunter = newVehicle.GetComponent<StuntDetect>(); } engine = newVehicle.GetComponentInChildren<Motor>(); propertySetter = newVehicle.GetComponent<PropertyToggleSetter>(); stuntText.gameObject.SetActive(stuntMode); scoreText.gameObject.SetActive(stuntMode); }
void Start() { this.tr = this.transform; this.rb = (Rigidbody)F.GetTopmostParentComponent <Rigidbody>(this.tr); this.vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(this.tr); this.targetDrive = this.GetComponent <DriveForce>(); this.flippedSide = Vector3.Dot(this.tr.forward, this.vp.transform.right) < 0; this.flippedSideFactor = this.flippedSide ? -1 : 1; this.initialRotation = this.tr.localRotation; if (Application.isPlaying) { this.GetCamber(); //Generate the hard collider if (this.generateHardCollider) { var cap = new GameObject("Compress Collider"); cap.layer = GlobalControl.ignoreWheelCastLayer; this.compressTr = cap.transform; this.compressTr.parent = this.tr; this.compressTr.localPosition = Vector3.zero; this.compressTr.localEulerAngles = new Vector3(this.camberAngle, 0, -this.casterAngle * this.flippedSideFactor); this.compressCol = cap.AddComponent <CapsuleCollider>(); this.compressCol.direction = 1; this.setHardColliderRadiusFactor = this.hardColliderRadiusFactor; this.hardColliderRadiusFactorPrev = this.setHardColliderRadiusFactor; this.compressCol.radius = this.wheel.rimWidth * this.hardColliderRadiusFactor; this.compressCol.height = (this.wheel.popped ? this.wheel.rimRadius : Mathf.Lerp(this.wheel.rimRadius, this.wheel.tireRadius, this.wheel.tirePressure)) * 2; this.compressCol.material = GlobalControl.frictionlessMatStatic; } this.steerRangeMax = Mathf.Max(this.steerRangeMin, this.steerRangeMax); this.properties = this.GetComponent <SuspensionPropertyToggle>(); if (this.properties) { this.UpdateProperties(); } } }
void Start() { vp = GetComponent<VehicleParent>(); //Get transmission for using reverse lights if (transmission) { if (transmission is GearboxTransmission) { gearTrans = transmission as GearboxTransmission; } else if (transmission is ContinuousTransmission) { conTrans = transmission as ContinuousTransmission; } } }
void Start() { this.vp = this.GetComponent <VehicleParent>(); //Get transmission for using reverse lights if (this.transmission) { if (this.transmission is GearboxTransmission) { this.gearTrans = this.transmission as GearboxTransmission; } else if (this.transmission is ContinuousTransmission) { this.conTrans = this.transmission as ContinuousTransmission; } } }
void Start() { this.snd = this.GetComponent <AudioSource>(); this.vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(this.transform); this.wheels = new Wheel[this.vp.wheels.Length]; //Get wheels and average slip threshold for (var i = 0; i < this.vp.wheels.Length; i++) { this.wheels[i] = this.vp.wheels[i]; if (this.vp.wheels[i].GetComponent <TireMarkCreate>()) { var newThreshold = this.vp.wheels[i].GetComponent <TireMarkCreate>().slipThreshold; this.slipThreshold = i == 0 ? newThreshold : (this.slipThreshold + newThreshold) * 0.5f; } } }
void Start() { snd = GetComponent <AudioSource>(); vp = transform.root.GetComponent <VehicleParent>(); wheels = new Wheel[vp.wheels.Length]; //Get wheels and average slip threshold for (int i = 0; i < vp.wheels.Length; i++) { wheels[i] = vp.wheels[i]; if (vp.wheels[i].GetComponent <TireMarkCreate>()) { float newThreshold = vp.wheels[i].GetComponent <TireMarkCreate>().slipThreshold; slipThreshold = i == 0 ? newThreshold : (slipThreshold + newThreshold) * 0.5f; } } }
void Start() { snd = GetComponent<AudioSource>(); vp = transform.root.GetComponent<VehicleParent>(); wheels = new Wheel[vp.wheels.Length]; //Get wheels and average slip threshold for (int i = 0; i < vp.wheels.Length; i++) { wheels[i] = vp.wheels[i]; if (vp.wheels[i].GetComponent<TireMarkCreate>()) { float newThreshold = vp.wheels[i].GetComponent<TireMarkCreate>().slipThreshold; slipThreshold = i == 0 ? newThreshold : (slipThreshold + newThreshold) * 0.5f; } } }
public void SpawnVehicle(int vehicle = 0) { //newVehicle = Instantiate(vehicles[vehicle], spawnPoint, Quaternion.LookRotation(spawnRot, GlobalControl.worldUpDir)) as GameObject; //cam.target = newVehicle.transform; //cam.Initialize(); vp = newVehicle.GetComponent <VehicleParent>(); trans = newVehicle.GetComponentInChildren <Transmission>(); if (trans) { trans.automatic = autoShift; //newVehicle.GetComponent<VehicleParent>().brakeIsReverse = autoShift; if (trans is GearboxTransmission) { gearbox = trans as GearboxTransmission; } else if (trans is ContinuousTransmission) { varTrans = trans as ContinuousTransmission; if (!autoShift) { vp.brakeIsReverse = true; } } } if (newVehicle.GetComponent <VehicleAssist>()) { newVehicle.GetComponent <VehicleAssist>().enabled = assist; } if (newVehicle.GetComponent <FlipControl>() && newVehicle.GetComponent <StuntDetect>()) { newVehicle.GetComponent <FlipControl>().flipPower = stuntMode && assist ? new Vector3(10, 10, -10) : Vector3.zero; newVehicle.GetComponent <FlipControl>().rotationCorrection = stuntMode ? Vector3.zero : (assist ? new Vector3(5, 1, 10) : Vector3.zero); newVehicle.GetComponent <FlipControl>().stopFlip = assist; //stunter = newVehicle.GetComponent<StuntDetect>(); } engine = newVehicle.GetComponentInChildren <Motor>(); propertySetter = newVehicle.GetComponent <PropertyToggleSetter>(); stuntText.gameObject.SetActive(stuntMode); scoreText.gameObject.SetActive(stuntMode); }
void Start() { tr = transform; rb = GetComponent <Rigidbody>(); vp = GetComponent <VehicleParent>(); //Tell VehicleParent not to play crashing sounds because this script takes care of it vp.playCrashSounds = false; vp.playCrashSparks = false; //Set up mesh data tempMeshes = new Mesh[deformMeshes.Length]; damagedMeshes = new bool[deformMeshes.Length]; meshVertices = new meshVerts[deformMeshes.Length]; for (int i = 0; i < deformMeshes.Length; i++) { tempMeshes[i] = deformMeshes[i].mesh; meshVertices[i] = new meshVerts(); meshVertices[i].verts = deformMeshes[i].mesh.vertices; meshVertices[i].initialVerts = deformMeshes[i].mesh.vertices; damagedMeshes[i] = false; } //Set up mesh collider data tempCols = new Mesh[deformColliders.Length]; damagedCols = new bool[deformColliders.Length]; colVertices = new meshVerts[deformColliders.Length]; for (int i = 0; i < deformColliders.Length; i++) { tempCols[i] = (Mesh)Instantiate(deformColliders[i].sharedMesh); colVertices[i] = new meshVerts(); colVertices[i].verts = deformColliders[i].sharedMesh.vertices; colVertices[i].initialVerts = deformColliders[i].sharedMesh.vertices; damagedCols[i] = false; } //Set initial positions for displaced parts initialPartPositions = new Vector3[displaceParts.Length]; for (int i = 0; i < displaceParts.Length; i++) { initialPartPositions[i] = displaceParts[i].localPosition; } }
void Start() { this.tr = this.transform; this.rb = this.GetComponent <Rigidbody>(); this.vp = this.GetComponent <VehicleParent>(); //Tell VehicleParent not to play crashing sounds because this script takes care of it this.vp.playCrashSounds = false; this.vp.playCrashSparks = false; //Set up mesh data this.tempMeshes = new Mesh[this.deformMeshes.Length]; this.damagedMeshes = new bool[this.deformMeshes.Length]; this.meshVertices = new meshVerts[this.deformMeshes.Length]; for (var i = 0; i < this.deformMeshes.Length; i++) { this.tempMeshes[i] = this.deformMeshes[i].mesh; this.meshVertices[i] = new meshVerts(); this.meshVertices[i].verts = this.deformMeshes[i].mesh.vertices; this.meshVertices[i].initialVerts = this.deformMeshes[i].mesh.vertices; this.damagedMeshes[i] = false; } //Set up mesh collider data this.tempCols = new Mesh[this.deformColliders.Length]; this.damagedCols = new bool[this.deformColliders.Length]; this.colVertices = new meshVerts[this.deformColliders.Length]; for (var i = 0; i < this.deformColliders.Length; i++) { this.tempCols[i] = Instantiate(this.deformColliders[i].sharedMesh); this.colVertices[i] = new meshVerts(); this.colVertices[i].verts = this.deformColliders[i].sharedMesh.vertices; this.colVertices[i].initialVerts = this.deformColliders[i].sharedMesh.vertices; this.damagedCols[i] = false; } //Set initial positions for displaced parts this.initialPartPositions = new Vector3[this.displaceParts.Length]; for (var i = 0; i < this.displaceParts.Length; i++) { this.initialPartPositions[i] = this.displaceParts[i].localPosition; } }
void Start() { tr = transform; rb = GetComponent<Rigidbody>(); vp = GetComponent<VehicleParent>(); //Tell VehicleParent not to play crashing sounds because this script takes care of it vp.playCrashSounds = false; vp.playCrashSparks = false; //Set up mesh data tempMeshes = new Mesh[deformMeshes.Length]; damagedMeshes = new bool[deformMeshes.Length]; meshVertices = new meshVerts[deformMeshes.Length]; for (int i = 0; i < deformMeshes.Length; i++) { tempMeshes[i] = deformMeshes[i].mesh; meshVertices[i] = new meshVerts(); meshVertices[i].verts = deformMeshes[i].mesh.vertices; meshVertices[i].initialVerts = deformMeshes[i].mesh.vertices; damagedMeshes[i] = false; } //Set up mesh collider data tempCols = new Mesh[deformColliders.Length]; damagedCols = new bool[deformColliders.Length]; colVertices = new meshVerts[deformColliders.Length]; for (int i = 0; i < deformColliders.Length; i++) { tempCols[i] = (Mesh)Instantiate(deformColliders[i].sharedMesh); colVertices[i] = new meshVerts(); colVertices[i].verts = deformColliders[i].sharedMesh.vertices; colVertices[i].initialVerts = deformColliders[i].sharedMesh.vertices; damagedCols[i] = false; } //Set initial positions for displaced parts initialPartPositions = new Vector3[displaceParts.Length]; for (int i = 0; i < displaceParts.Length; i++) { initialPartPositions[i] = displaceParts[i].localPosition; } }
void Start() { tr = transform; rb = (Rigidbody)F.GetTopmostParentComponent <Rigidbody>(tr); vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(tr); targetDrive = GetComponent <DriveForce>(); flippedSide = Vector3.Dot(tr.forward, vp.transform.right) < 0; flippedSideFactor = flippedSide ? -1 : 1; initialRotation = tr.localRotation; if (Application.isPlaying) { GetCamber(); //Generate the hard collider if (generateHardCollider) { GameObject cap = new GameObject("Compress Collider"); cap.layer = GlobalControl.ignoreWheelCastLayer; compressTr = cap.transform; compressTr.parent = tr; compressTr.localPosition = Vector3.zero; compressTr.localEulerAngles = new Vector3(camberAngle, 0, -casterAngle * flippedSideFactor); compressCol = cap.AddComponent <CapsuleCollider>(); compressCol.direction = 1; setHardColliderRadiusFactor = hardColliderRadiusFactor; hardColliderRadiusFactorPrev = setHardColliderRadiusFactor; compressCol.radius = wheel.rimWidth * hardColliderRadiusFactor; compressCol.height = (wheel.popped ? wheel.rimRadius : Mathf.Lerp(wheel.rimRadius, wheel.tireRadius, wheel.tirePressure)) * 2; compressCol.material = GlobalControl.frictionlessMatStatic; } steerRangeMax = Mathf.Max(steerRangeMin, steerRangeMax); properties = GetComponent <SuspensionPropertyToggle>(); if (properties) { UpdateProperties(); } } }
void Start() { tr = transform; rb = tr.root.GetComponent <Rigidbody>(); vp = tr.root.GetComponent <VehicleParent>(); flippedSideFactor = Vector3.Dot(tr.forward, tr.root.right) < 0 ? 1 : -1; canDetach = detachForce < Mathf.Infinity && Application.isPlaying; if (canDetach) { detachedWheel = new GameObject("Detached Wheel"); detachedWheel.layer = LayerMask.NameToLayer("Detachable Part"); detachFilter = detachedWheel.AddComponent <MeshFilter>(); detachFilter.sharedMesh = visualWheel.GetComponent <MeshFilter>().sharedMesh; MeshRenderer detachRend = detachedWheel.AddComponent <MeshRenderer>(); detachRend.sharedMaterial = visualWheel.GetComponent <MeshRenderer>().sharedMaterial; detachedCol = detachedWheel.AddComponent <MeshCollider>(); detachedCol.convex = true; detachedBody = detachedWheel.AddComponent <Rigidbody>(); detachedBody.mass = mass; detachedWheel.SetActive(false); } }
void Start() { tr = transform; rb = tr.root.GetComponent<Rigidbody>(); vp = tr.root.GetComponent<VehicleParent>(); flippedSideFactor = Vector3.Dot(tr.forward, tr.root.right) < 0 ? 1 : -1; canDetach = detachForce < Mathf.Infinity && Application.isPlaying; if (canDetach) { detachedWheel = new GameObject("Detached Wheel"); detachedWheel.layer = LayerMask.NameToLayer("Detachable Part"); detachFilter = detachedWheel.AddComponent<MeshFilter>(); detachFilter.sharedMesh = visualWheel.GetComponent<MeshFilter>().sharedMesh; MeshRenderer detachRend = detachedWheel.AddComponent<MeshRenderer>(); detachRend.sharedMaterial = visualWheel.GetComponent<MeshRenderer>().sharedMaterial; detachedCol = detachedWheel.AddComponent<MeshCollider>(); detachedCol.convex = true; detachedBody = detachedWheel.AddComponent<Rigidbody>(); detachedBody.mass = mass; detachedWheel.SetActive(false); } }
public void Initialize() { //lookObj is an object used to help position and rotate the camera if (!lookObj) { GameObject lookTemp = new GameObject("Camera Looker"); lookObj = lookTemp.transform; } //Set variables based on target vehicle's properties if (target) { vp = target.GetComponent <VehicleParent>(); distance += vp.cameraDistanceChange; height += vp.cameraHeightChange; forwardLook = target.forward; upLook = target.up; targetBody = target.GetComponent <Rigidbody>(); } //Set the audio listener update mode to fixed, because the camera moves in FixedUpdate //This is necessary for doppler effects to sound correct GetComponent <AudioListener>().velocityUpdateMode = AudioVelocityUpdateMode.Fixed; }
void Start() { this.tr = this.transform; this.rb = (Rigidbody)F.GetTopmostParentComponent <Rigidbody>(this.tr); this.vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(this.tr); this.flippedSideFactor = Vector3.Dot(this.tr.forward, this.vp.transform.right) < 0 ? 1 : -1; this.canDetach = this.detachForce < Mathf.Infinity && Application.isPlaying; this.bufferDistance = Mathf.Min(this.hoverDistance, this.bufferDistance); if (this.canDetach) { this.detachedWheel = new GameObject(this.vp.transform.name + "'s Detached Wheel"); this.detachedWheel.layer = LayerMask.NameToLayer("Detachable Part"); this.detachFilter = this.detachedWheel.AddComponent <MeshFilter>(); this.detachFilter.sharedMesh = this.visualWheel.GetComponent <MeshFilter>().sharedMesh; var detachRend = this.detachedWheel.AddComponent <MeshRenderer>(); detachRend.sharedMaterial = this.visualWheel.GetComponent <MeshRenderer>().sharedMaterial; this.detachedCol = this.detachedWheel.AddComponent <MeshCollider>(); this.detachedCol.convex = true; this.detachedBody = this.detachedWheel.AddComponent <Rigidbody>(); this.detachedBody.mass = this.mass; this.detachedWheel.SetActive(false); } }
public void Initialize() { //lookObj is an object used to help position and rotate the camera if (!lookObj) { GameObject lookTemp = new GameObject("Camera Looker"); lookObj = lookTemp.transform; } //Set variables based on target vehicle's properties if (target) { vp = target.GetComponent<VehicleParent>(); distance += vp.cameraDistanceChange; height += vp.cameraHeightChange; forwardLook = target.forward; upLook = target.up; targetBody = target.GetComponent<Rigidbody>(); } //Set the audio listener update mode to fixed, because the camera moves in FixedUpdate //This is necessary for doppler effects to sound correct GetComponent<AudioListener>().velocityUpdateMode = AudioVelocityUpdateMode.Fixed; }
void Start() { vp = GetComponent <VehicleParent>(); setter = FindObjectOfType <MobileInput>(); }
void Start() { tr = transform; rb = (Rigidbody)F.GetTopmostParentComponent<Rigidbody>(tr); vp = (VehicleParent)F.GetTopmostParentComponent<VehicleParent>(tr); suspensionParent = tr.parent.GetComponent<Suspension>(); travelDist = suspensionParent.targetCompression; canDetach = detachForce < Mathf.Infinity && Application.isPlaying; initialTirePressure = tirePressure; if (tr.childCount > 0) { //Get rim rim = tr.GetChild(0); //Set up rim glow material if (rimGlow > 0 && Application.isPlaying) { rimMat = new Material(rim.GetComponent<MeshRenderer>().sharedMaterial); rimMat.EnableKeyword("_EMISSION"); rim.GetComponent<MeshRenderer>().material = rimMat; } //Create detached wheel if (canDetach) { detachedWheel = new GameObject(vp.transform.name + "'s Detached Wheel"); detachedWheel.layer = LayerMask.NameToLayer("Detachable Part"); detachFilter = detachedWheel.AddComponent<MeshFilter>(); detachFilter.sharedMesh = rim.GetComponent<MeshFilter>().sharedMesh; MeshRenderer detachRend = detachedWheel.AddComponent<MeshRenderer>(); detachRend.sharedMaterial = rim.GetComponent<MeshRenderer>().sharedMaterial; detachedCol = detachedWheel.AddComponent<MeshCollider>(); detachedCol.convex = true; detachedBody = detachedWheel.AddComponent<Rigidbody>(); detachedBody.mass = mass; } //Get tire if (rim.childCount > 0) { tire = rim.GetChild(0); if (deformAmount > 0 && Application.isPlaying) { tireMat = new Material(tire.GetComponent<MeshRenderer>().sharedMaterial); tire.GetComponent<MeshRenderer>().material = tireMat; } //Create detached tire if (canDetach) { detachedTire = new GameObject("Detached Tire"); detachedTire.transform.parent = detachedWheel.transform; detachedTire.transform.localPosition = Vector3.zero; detachedTire.transform.localRotation = Quaternion.identity; detachTireFilter = detachedTire.AddComponent<MeshFilter>(); detachTireFilter.sharedMesh = tire.GetComponent<MeshFilter>().sharedMesh; MeshRenderer detachTireRend = detachedTire.AddComponent<MeshRenderer>(); detachTireRend.sharedMaterial = tireMat ? tireMat : tire.GetComponent<MeshRenderer>().sharedMaterial; } } if (Application.isPlaying) { //Generate hard collider if (generateHardCollider) { GameObject sphereColNew = new GameObject("Rim Collider"); sphereColNew.layer = GlobalControl.ignoreWheelCastLayer; sphereColTr = sphereColNew.transform; sphereCol = sphereColNew.AddComponent<SphereCollider>(); sphereColTr.parent = tr; sphereColTr.localPosition = Vector3.zero; sphereColTr.localRotation = Quaternion.identity; sphereCol.radius = Mathf.Min(rimWidth * 0.5f, rimRadius * 0.5f); sphereCol.material = GlobalControl.frictionlessMatStatic; } if (canDetach) { detachedWheel.SetActive(false); } } } targetDrive = GetComponent<DriveForce>(); currentRPM = 0; }
void Start() { vp = GetComponent<VehicleParent>(); }
void Start() { tr = transform; vp = transform.root.GetComponent<VehicleParent>(); }
void Start() { vp = GetComponent <VehicleParent>(); lg = GetComponent <LightController> (); engine = vp.engine; }
void Start() { tr = transform; vp = transform.root.GetComponent<VehicleParent>(); steerRot = rotationOffset; }
public virtual void Start() { vp = transform.root.GetComponent<VehicleParent>(); targetDrive = GetComponent<DriveForce>(); newDrive = gameObject.AddComponent<DriveForce>(); }
public virtual void Start() { vp = transform.root.GetComponent <VehicleParent>(); targetDrive = GetComponent <DriveForce>(); newDrive = gameObject.AddComponent <DriveForce>(); }
public override void OnInspectorGUI() { GUIStyle boldFoldout = new GUIStyle(EditorStyles.foldout); boldFoldout.fontStyle = FontStyle.Bold; VehicleParent targetScript = (VehicleParent)target; VehicleParent[] allTargets = new VehicleParent[targets.Length]; isPrefab = PrefabUtility.GetPrefabType(targetScript) == PrefabType.Prefab; for (int i = 0; i < targets.Length; i++) { Undo.RecordObject(targets[i], "Vehicle Parent Change"); allTargets[i] = targets[i] as VehicleParent; } wheelMissing = false; if (targetScript.wheelGroups != null) { if (targetScript.wheelGroups.Length > 0) { if (targetScript.hover) { foreach (HoverWheel curWheel in targetScript.hoverWheels) { bool wheelfound = false; foreach (WheelCheckGroup curGroup in targetScript.wheelGroups) { foreach (HoverWheel curWheelInstance in curGroup.hoverWheels) { if (curWheel == curWheelInstance) { wheelfound = true; } } } if (!wheelfound) { wheelMissing = true; break; } } } else { foreach (Wheel curWheel in targetScript.wheels) { bool wheelfound = false; foreach (WheelCheckGroup curGroup in targetScript.wheelGroups) { foreach (Wheel curWheelInstance in curGroup.wheels) { if (curWheel == curWheelInstance) { wheelfound = true; } } } if (!wheelfound) { wheelMissing = true; break; } } } } } if (wheelMissing) { EditorGUILayout.HelpBox("If there is at least one wheel group, all wheels must be part of a group.", MessageType.Error); } DrawDefaultInspector(); if (!isPrefab && targetScript.gameObject.activeInHierarchy) { showButtons = EditorGUILayout.Foldout(showButtons, "Quick Actions", boldFoldout); EditorGUI.indentLevel ++; if (showButtons) { if (GUILayout.Button("Get Engine")) { foreach (VehicleParent curTarget in allTargets) { curTarget.engine = curTarget.transform.GetComponentInChildren<Motor>(); } } if (GUILayout.Button("Get Wheels")) { foreach (VehicleParent curTarget in allTargets) { if (curTarget.hover) { curTarget.hoverWheels = curTarget.transform.GetComponentsInChildren<HoverWheel>(); } else { curTarget.wheels = curTarget.transform.GetComponentsInChildren<Wheel>(); } } } } EditorGUI.indentLevel --; } if (GUI.changed) { EditorUtility.SetDirty(targetScript); } }
public override void OnInspectorGUI() { GUIStyle boldFoldout = new GUIStyle(EditorStyles.foldout); boldFoldout.fontStyle = FontStyle.Bold; VehicleParent targetScript = (VehicleParent)target; VehicleParent[] allTargets = new VehicleParent[targets.Length]; isPrefab = PrefabUtility.GetPrefabType(targetScript) == PrefabType.Prefab; for (int i = 0; i < targets.Length; i++) { Undo.RecordObject(targets[i], "Vehicle Parent Change"); allTargets[i] = targets[i] as VehicleParent; } wheelMissing = false; if (targetScript.wheelGroups != null) { if (targetScript.wheelGroups.Length > 0) { if (targetScript.hover) { foreach (HoverWheel curWheel in targetScript.hoverWheels) { bool wheelfound = false; foreach (WheelCheckGroup curGroup in targetScript.wheelGroups) { foreach (HoverWheel curWheelInstance in curGroup.hoverWheels) { if (curWheel == curWheelInstance) { wheelfound = true; } } } if (!wheelfound) { wheelMissing = true; break; } } } else { foreach (Wheel curWheel in targetScript.wheels) { bool wheelfound = false; foreach (WheelCheckGroup curGroup in targetScript.wheelGroups) { foreach (Wheel curWheelInstance in curGroup.wheels) { if (curWheel == curWheelInstance) { wheelfound = true; } } } if (!wheelfound) { wheelMissing = true; break; } } } } } if (wheelMissing) { EditorGUILayout.HelpBox("If there is at least one wheel group, all wheels must be part of a group.", MessageType.Error); } DrawDefaultInspector(); if (!isPrefab && targetScript.gameObject.activeInHierarchy) { showButtons = EditorGUILayout.Foldout(showButtons, "Quick Actions", boldFoldout); EditorGUI.indentLevel++; if (showButtons) { if (GUILayout.Button("Get Engine")) { foreach (VehicleParent curTarget in allTargets) { curTarget.engine = curTarget.transform.GetComponentInChildren <Motor>(); } } if (GUILayout.Button("Get Wheels")) { foreach (VehicleParent curTarget in allTargets) { if (curTarget.hover) { curTarget.hoverWheels = curTarget.transform.GetComponentsInChildren <HoverWheel>(); } else { curTarget.wheels = curTarget.transform.GetComponentsInChildren <Wheel>(); } } } } EditorGUI.indentLevel--; } if (GUI.changed) { EditorUtility.SetDirty(targetScript); } }
void Start() { tr = transform; vp = (VehicleParent)F.GetTopmostParentComponent<VehicleParent>(tr); }
void Start() { tr = transform; rb = GetComponent<Rigidbody>(); vp = GetComponent<VehicleParent>(); }
void Start() { tr = transform; rb = transform.root.GetComponent<Rigidbody>(); vp = tr.root.GetComponent<VehicleParent>(); targetDrive = GetComponent<DriveForce>(); flippedSide = Vector3.Dot(tr.forward, tr.root.right) < 0; flippedSideFactor = flippedSide ? -1 : 1; initialRotation = tr.localRotation; if (Application.isPlaying) { GetCamber(); //Generate the hard collider if (generateHardCollider) { GameObject cap = new GameObject("Compress Collider"); cap.layer = GlobalControl.ignoreWheelCastLayer; compressTr = cap.transform; compressTr.parent = tr; compressTr.localPosition = Vector3.zero; compressTr.localEulerAngles = new Vector3(camberAngle, 0, -casterAngle * flippedSideFactor); compressCol = cap.AddComponent<CapsuleCollider>(); compressCol.direction = 1; setHardColliderRadiusFactor = hardColliderRadiusFactor; hardColliderRadiusFactorPrev = setHardColliderRadiusFactor; compressCol.radius = wheel.rimWidth * hardColliderRadiusFactor; compressCol.height = (wheel.popped ? wheel.rimRadius : Mathf.Lerp(wheel.rimRadius, wheel.tireRadius, wheel.tirePressure)) * 2; compressCol.material = GlobalControl.frictionlessMatStatic; } steerRangeMax = Mathf.Max(steerRangeMin, steerRangeMax); properties = GetComponent<SuspensionPropertyToggle>(); if (properties) { UpdateProperties(); } } }
void Start() { vp = GetComponent<VehicleParent>(); setter = FindObjectOfType<MobileInput>(); }
void Start() { this.tr = this.transform; this.rb = this.GetComponent <Rigidbody>(); this.vp = this.GetComponent <VehicleParent>(); }
void Start() { tr = transform; rb = GetComponent <Rigidbody>(); vp = GetComponent <VehicleParent>(); }
void Start() { this.vp = this.GetComponent <VehicleParent>(); this.setter = FindObjectOfType <MobileInput>(); }
void Start() { this.tr = this.transform; this.vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(this.tr); }
void Start() { this.vp = this.GetComponent <VehicleParent>(); }
void Start() { tr = transform; vp = (VehicleParent)F.GetTopmostParentComponent<VehicleParent>(tr); steerRot = rotationOffset; }