SchultzGames
Para tirar dúvidas, crie um tópico especifico na área "Dúvidas em Geral" e aguarde ser respondido. Evite comentar em tópicos não relacionados a sua dúvida :D
TÓPICOS RECENTES:
Tópico:
Postado em:
Postado por:
ShapeKeys do Blender para a Unity altera áreas próximas
COMO EVITAR QUE UM OBJETO (PLAYER,ITEM ETC...) ATRAVESSE UMA PAREDE.
Ajuda em Script de Verificação de Ação e Reação
unity Failed to load PlayerSettings (internal index #0). Most likely data f
modelar avatar e skins para um jogo web
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Materiais do Blander não aparecem no MeshRendere do Objeto na Unity
Repetiçoes de Textura no Terreno
SERVER IS DOWN - UNITY+MSQL
Procuro programadores - Novo jogo
Problema com o MS VEHICLES
Preciso de ajuda com a Unity
Problema com vídeo em 360° na Unity
Problemas no MS Vehicles
unity- eventos na Animação com Armature/Bones vinda do blender não funciona
ajuda exibir resultados simulados em uma liga Game Unity
Unity - ParticleSystem não é redirecionado no rawimage no canvas
Como resolver o problema de "face orientation" no Blender.
[DÚVIDA] Tive um problema com meu Canvas
erro na Directional Light
Problemas com o Directional Light da Unity 3D
210 Linhas de código para inimigo é muito grande?
Novo jogo da franquia Sphere game em desenvolvimento
malha da roda não girando com wheel collider unity
Problemas com ambiguidade
Touch mobile
INVALID TOKEN
Como acessar o "HD Render Pipeline" do HDRP por script?
CHAT GPT PRA JOGO DE TIRO? comentem
Tutorial script inimigo segue e foge do player
Ainda vale a pena lançar Asset na Asset Store?
Ajuda com tabela de historico de pontuaçao.
[TUTORIAL] Entrar no carro estilo GTA
Como derrapar um Whell Collider
Como altertar o valor do "Asymptote Value" do Whell Collider via Script
Preciso de ajuda para substituir valor de variavel em outro script
Ajuda com Top Down Shooter utilizando Photon
Duvida com Netcode
[RESOLVIDO] Unity - Movendo a Câmera na Horizontal/Vertical com Touch
Alguém me ajuda com os anúncios pfv
Segundo Trailer do jogo Dark Age, Feliz Natal a todos!
Unity - ScrollRect, Viewport, Content - O Conteúdo ñ inicia no topo
Coleta de itens
Unity - Cadastro do email do jogador
[GRATIS] PACK DE MODELOS 3D PARA JOGO DE TERROR
Onde Conseguir músicas para meu Jogo?
error CS0246 em Script
Alguem teve ja esse problema?
[Projeto em Andamento] Draug, um jogo de hordas
DISPONIVEL PARA FAZER MODELOS 3D
Unity-Loja.Como os Jogadores terão acesso aos ítens comprados na PlayStore?
Bugando depois do Build.
Primeiro Trailer do jogo Dark Age
Problema com sombra
Mesh e Material do objeto trocando para uma instancia no inicio do jogo
[RESOLVIDO] Unity - RawImages_Layer_Camera
INVESTIMENTO EM JOGOS E BANCO DE TALENTO
Teaser do meu novo projeto pessoal, Dark Age
Preciso de ajuda com mudança para mobile androide.
[RESOLVIDO] Posição final do objeto em jogo 2D
Input.GetAxis() obedercer a orientação de um objeto.
Interação com elementos UI
Meu primeiro jogo na steam
Minimap/Radar/GPS Estilo GTA V
[RESOLVIDO] Erro no console depois que formatei o pc
PACK GRÁTIS de Músicas ELETRÔNICAS para ajudar vocês em seus Jogos Indies!
[TUTORIAL] Entenda como funciona: ENUM, SWITCH, BREAK, CASE no C#
O Labirinto II - Baixe o Jogo
Qual e o codigo de Botões na unity para saber seus estados?
Como carregar itens pequenos dentro do carro sem que atravesse os colliders
[Duvida] Script pegar itens
Travamento ao trocar de cena
Colisão zoada e movimentação
Salvar objetos que foram destruidos entre cenas na unity
Quero começa a desenvolver um jogo de luta porem eu queria aprender a faze
Pegar qual objeto colidiu com o Linecast.
movimentação e camera?
[RESOLVIDO] Unity - SceneManager.LoadScene abre scene com objeto "vazio"
[RESOLVIDO] ajuda sobre skybox
MEU SIMULADOR DE CARRO
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY
[RESOLVIDO] Ausencia da funçao NavMesh na Unity 2022.2.12
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY - 2
Roll Up Um jogo de aventura e desáfios
Terminologia da Unity em outras engines
Como criar a iluminação do Sol no Sistema Solar?
Conexão de lobby pelo OnConnectedToMaster
Problema na exportção de projeto unity
[RESOLVIDO] Unity - Áudios estão emitindo som só Depois do Botão ser solto
Unity - Banco de Dados Online junto ao Jogo
Player virar para o inimigo(Prefab)
[TUTORIAL] Sistema De Save Game Ao Sair Da Fase
Problema de Sincronização de um objeto de um jogo multiplayer usa q Photon
Unity - Compartilhar meu Jogo
Alguém que manja do Google ADmob?
Unity - Avaliar meu Jogo
[RESOLVIDO] Destruir inimigo com o player.
Salvar e carregar dados na Unity de objetos prefabs sem sobrescrever os dad
Unity - Salvar os Dados do Jogador Online
Ontem à(s) 10:09 pm
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
Qua Fev 21, 2024 10:39 am
Ter Fev 20, 2024 9:28 am
Ter Fev 20, 2024 12:15 am
Seg Fev 19, 2024 1:06 pm
Seg Fev 12, 2024 1:56 pm
Seg Fev 12, 2024 1:17 pm
Dom Fev 11, 2024 8:55 pm
Dom Fev 11, 2024 11:16 am
Seg Fev 05, 2024 4:18 pm
Dom Fev 04, 2024 9:39 pm
Qua Jan 31, 2024 11:59 pm
Ter Jan 30, 2024 7:37 pm
Ter Jan 23, 2024 6:33 pm
Dom Jan 21, 2024 6:03 pm
Sáb Jan 20, 2024 7:03 pm
Sáb Jan 20, 2024 6:58 pm
Sáb Jan 20, 2024 6:39 pm
Sex Jan 19, 2024 1:29 pm
Sex Jan 19, 2024 8:40 am
Dom Jan 14, 2024 5:30 pm
Qua Jan 10, 2024 10:29 pm
Qua Jan 10, 2024 8:55 pm
Qua Jan 10, 2024 7:14 pm
Ter Jan 09, 2024 3:55 pm
Ter Jan 09, 2024 8:04 am
Sáb Jan 06, 2024 8:02 pm
Sex Jan 05, 2024 7:01 am
Sex Jan 05, 2024 12:12 am
Qui Jan 04, 2024 6:55 pm
Qui Jan 04, 2024 12:52 pm
Qui Jan 04, 2024 4:34 am
Ter Jan 02, 2024 11:48 pm
Dom Dez 31, 2023 7:25 pm
Qua Dez 27, 2023 5:44 pm
Qua Dez 27, 2023 3:08 pm
Sáb Dez 23, 2023 7:27 pm
Sáb Dez 23, 2023 5:06 pm
Qui Dez 21, 2023 8:10 pm
Seg Dez 18, 2023 2:04 pm
Sex Dez 15, 2023 5:11 pm
Qui Dez 14, 2023 9:13 pm
Qui Dez 14, 2023 2:47 pm
Qui Dez 14, 2023 1:48 pm
Qua Dez 13, 2023 8:58 pm
Ter Dez 12, 2023 2:32 pm
Seg Dez 11, 2023 1:53 pm
Qua Dez 06, 2023 8:13 pm
Sáb Dez 02, 2023 8:06 pm
Qui Nov 30, 2023 7:49 am
Seg Nov 27, 2023 1:35 am
Qua Nov 22, 2023 7:37 am
Qui Nov 09, 2023 1:22 pm
Seg Nov 06, 2023 11:59 am
Ter Out 31, 2023 9:53 am
Dom Out 29, 2023 8:05 pm
Dom Out 29, 2023 3:03 am
Sex Out 27, 2023 3:43 pm
Sex Out 27, 2023 3:28 pm
Qua Out 25, 2023 1:20 pm
Seg Out 23, 2023 10:34 am
Dom Out 22, 2023 6:55 pm
Qui Out 19, 2023 11:57 pm
Qui Out 19, 2023 6:39 pm
Ter Out 17, 2023 6:37 pm
Ter Out 17, 2023 6:18 pm
Seg Out 16, 2023 1:59 pm
Sáb Out 14, 2023 12:15 pm
Qua Out 11, 2023 6:07 pm
Seg Out 09, 2023 4:19 pm
Qua Out 04, 2023 12:12 pm
Qua Out 04, 2023 12:11 pm
Ter Out 03, 2023 9:18 pm
Ter Out 03, 2023 9:08 pm
Ter Out 03, 2023 6:05 pm
Ter Set 26, 2023 12:45 pm
Seg Set 25, 2023 9:02 pm
Seg Set 25, 2023 9:47 am
Sáb Set 23, 2023 2:10 pm
Sex Set 22, 2023 9:01 pm
Qui Set 21, 2023 11:04 am
Qua Set 20, 2023 4:40 pm
Qua Set 20, 2023 9:15 am
Dom Set 17, 2023 12:17 pm
Sex Set 15, 2023 7:24 pm
Sex Set 15, 2023 5:41 pm
Sex Set 15, 2023 4:28 pm
Sex Set 15, 2023 10:56 am
Sex Set 15, 2023 10:15 am
Seg Set 11, 2023 11:43 am
Seg Set 11, 2023 11:31 am
Sáb Set 09, 2023 4:53 pm
Sáb Set 09, 2023 1:44 pm
Ter Set 05, 2023 11:12 pm
Ter Set 05, 2023 3:12 pm
Seg Set 04, 2023 11:53 pm



































































































[DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

4 participantes

Ir para baixo

DÚVIDA [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por fabriciorsz34 Qua Jan 17, 2018 9:16 pm

Oi gente,tenho um script que ha um tempo atras funcionava certinho mas a unity atualizou e da esse erro agr:Assets/RealisticCarControllerV3/Scripts/RCC_CarControllerV3.cs(738,Cool: error CS0619: `UnityEngine.Mesh.Optimize()' is obsolete: `This method is no longer supported (UnityUpgradable)'
O script :



using UnityEngine;
using UnityEngine.Audio;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.EventSystems;

[AddComponentMenu("BoneCracker Games/Realistic Car Controller/Realistic Car Controller V3")]
[RequireComponent (typeof(Rigidbody))]
public class RCC_CarControllerV3 : MonoBehaviour {

private RCC_Settings RCCSettings{get{return RCC_Settings.Instance;}}
private Rigidbody rigid; // Rigidbody.
internal bool sleepingRigid = false; // Used For Disabling Unnecessary Raycasts When RB Is Sleeping.

public bool AIController = false; // Use AI Controller.

// Wheel Transforms Of The Vehicle.
public Transform FrontLeftWheelTransform;
public Transform FrontRightWheelTransform;
public Transform RearLeftWheelTransform;
public Transform RearRightWheelTransform;

// Wheel Colliders Of The Vehicle.
public RCC_WheelCollider FrontLeftWheelCollider;
public RCC_WheelCollider FrontRightWheelCollider;
public RCC_WheelCollider RearLeftWheelCollider;
public RCC_WheelCollider RearRightWheelCollider;

private RCC_WheelCollider FrontLeftRCCWheelCollider;
private RCC_WheelCollider FrontRightRCCWheelCollider;

// All Wheel Colliders.
internal RCC_WheelCollider[] allWheelColliders;

// Extra Wheels. In case of if your vehicle has extra wheels.
public Transform[] ExtraRearWheelsTransform;
public RCC_WheelCollider[] ExtraRearWheelsCollider;

public bool applyEngineTorqueToExtraRearWheelColliders = true; //Applies Engine Torque To Extra Rear Wheels.

public Transform SteeringWheel; // Driver Steering Wheel. In case of if your vehicle has individual steering wheel model in interior.

// Set wheel drive of the vehicle. If you are using rwd, you have to be careful with your rear wheel collider
// settings and com of the vehicle. Otherwise, vehicle will behave like a toy.
public WheelType _wheelTypeChoise = WheelType.RWD;
public enum WheelType{FWD, RWD, AWD, BIASED}
[Range(0f, 100f)]public float biasedWheelTorque = 100f;

//Center of mass.
public Transform COM;

public bool canControl = true; // Enables/Disables controlling the vehicle.
public bool runEngineAtAwake{get{return RCCSettings.runEngineAtAwake;}} // Engine Running At Awake?
public bool engineRunning = false; // Engine Running Now?
public bool autoReverse{get{return RCCSettings.autoReverse;}} // Enables/Disables auto reversing when player press brake button. Useful for if you are making parking style game.
public bool automaticGear{get{return RCCSettings.useAutomaticGear;}} // Enables/Disables automatic gear shifting of the vehicle.
public bool semiAutomaticGear = false; // Enables/Disables automatic gear shifting of the vehicle.
public bool automaticClutch = true; // Enables/Disables automatic clutch of the vehicle.
private bool canGoReverseNow = false;

public AnimationCurve[] engineTorqueCurve; // Each Gear Ratio Curves Generated By Editor Script.
public float[] gearSpeed; // Target Speed For Changing Gear.
public float engineTorque = 3000f; // Default Engine Torque.
public float maxEngineRPM = 7000f; // Maximum Engine RPM.
public float minEngineRPM = 1000f; // Minimum Engine RPM.
[Range(.75f, 2f)]public float engineInertia = 1f;
public bool useRevLimiter = true;
public bool useExhaustFlame = true;

public float steerAngle = 40f; // Maximum Steer Angle Of Your Vehicle.
public float highspeedsteerAngle = 15f; // Maximum Steer Angle At Highest Speed.
public float highspeedsteerAngleAtspeed = 100f; // Highest Speed For Maximum Steer Angle.
public float antiRollFrontHorizontal = 5000f; // Anti Roll Force For Preventing Flip Overs And Stability.
public float antiRollRearHorizontal = 5000f; // Anti Roll Force For Preventing Flip Overs And Stability.
public float antiRollVertical = 500f; // Anti Roll Force For Preventing Flip Overs And Stability.

//Downforce.
public float downForce = 25f; // Applies Downforce Related With Vehicle Speed.

public float speed; // Vehicle Speed.
public float brake = 2500f; // Maximum Brake Torque.
private float defMaxSpeed;
public float maxspeed = 220f; //Maximum Speed.

private float resetTime = 0f;
private float orgSteerAngle = 0f;
public float fuelInput = 1f;

// Gears.
public int currentGear = 0; // Current Gear Of The Vehicle.
public int totalGears = 6; // Total Gears Of The Vehicle.
[Range(0f, .5f)]public float gearShiftingDelay = .35f;
public bool changingGear = false; // Changing Gear Currently.
public int direction = 1; // Reverse Gear Currently.

public bool autoGenerateGearCurves = true;
public bool autoGenerateTargetSpeedsForChangingGear = true;
private bool engineStarting = false;

//AudioSources and AudioClips.
private AudioSource engineStartSound;
public AudioClip engineStartClip;
internal AudioSource engineSoundOn;
public AudioClip engineClipOn;
private AudioSource engineSoundOff;
public AudioClip engineClipOff;
private AudioSource engineSoundIdle;
public AudioClip engineClipIdle;
private AudioSource gearShiftingSound;
private AudioClip[] gearShiftingClips{get{return RCCSettings.gearShiftingClips;}}
private AudioSource crashSound;
private AudioClip[] crashClips{get{return RCCSettings.crashClips;}}
private AudioSource reversingSound;
private AudioClip reversingClip{get{return RCCSettings.reversingClip;}}
private AudioSource windSound;
private AudioClip windClip{get{return RCCSettings.windClip;}}
private AudioSource brakeSound;
private AudioClip brakeClip{get{return RCCSettings.brakeClip;}}
private AudioSource NOSSound;
private AudioClip NOSClip{get{return RCCSettings.NOSClip;}}
private AudioSource turboSound;
private AudioClip turboClip{get{return RCCSettings.turboClip;}}
private AudioSource blowSound;
private AudioClip blowClip{get{return RCCSettings.turboClip;}}

[Range(.25f, 1f)]public float minEngineSoundPitch = .75f;
[Range(1.25f, 2f)]public float maxEngineSoundPitch = 1.75f;
[Range(0f, 1f)]public float minEngineSoundVolume = .05f;
[Range(0f, 1f)]public float maxEngineSoundVolume = .85f;

private GameObject allAudioSources;
private GameObject allContactParticles;

// Inputs.
[HideInInspector]public float gasInput = 0f;
[HideInInspector]public float brakeInput = 0f;
[HideInInspector]public float steerInput = 0f;
[HideInInspector]public float clutchInput = 0f;
[HideInInspector]public float handbrakeInput = 0f;
[HideInInspector]public float boostInput = 1f;
[HideInInspector]public bool cutGas = false;
[HideInInspector]public float idleInput = 0f;

internal float _gasInput{get{

if(fuelInput <= .25f)
return 0f;

if(!automaticGear || semiAutomaticGear){
if(!changingGear && !cutGas)
return Mathf.Clamp01(gasInput);
else
return 0f;
}else{
if(!changingGear && !cutGas)
return (direction == 1 ? Mathf.Clamp01(gasInput) : Mathf.Clamp01(brakeInput));
else
return 0f;
}

}set{gasInput = value;}}

internal float _brakeInput{get{

if(!automaticGear || semiAutomaticGear){
return Mathf.Clamp01(brakeInput);
}else{
if(!cutGas)
return (direction == 1 ? Mathf.Clamp01(brakeInput) : Mathf.Clamp01(gasInput));
else
return 0f;
}

}set{brakeInput = value;}}

internal float _boostInput{get{

if(useNOS && NoS > 5 && _gasInput >= .5f){
return boostInput;
}else{
return 1f;
}

}set{boostInput = value;}}

internal float engineRPM = 0f; // Actual Engine RPM.
internal float rawEngineRPM = 0f; // Smoothed Engine RPM.

public GameObject chassis; // Script Will Simulate Chassis Movement Based On Vehicle Rigidbody Velocity.

// Lights.
public bool lowBeamHeadLightsOn = false;
public bool highBeamHeadLightsOn = false;

// For Indicators.
public IndicatorsOn indicatorsOn;
public enum IndicatorsOn{Off, Right, Left, All}
public float indicatorTimer = 0f;

// Damage.
public bool useDamage = true;
struct originalMeshVerts{public Vector3[] meshVerts;}
public MeshFilter[] deformableMeshFilters;
public float randomizeVertices = 1f;
public float damageRadius = .5f;

private float minimumVertDistanceForDamagedMesh = .002f; // Comparing Original Vertex Positions Between Last Vertex Positions To Decide Mesh Is Repaired Or Not.

private Vector3[] colliderVerts;
private originalMeshVerts[] originalMeshData;
[HideInInspector]public bool sleep = true;

public float maximumDamage = .5f; // Maximum Vert Distance For Limiting Damage. 0 Value Will Disable The Limit.
private float minimumCollisionForce = 5f;
public float damageMultiplier = 1f;

public GameObject contactSparkle{get{return RCCSettings.contactParticles;}}
public int maximumContactSparkle = 5;
private List<ParticleSystem> contactSparkeList = new List<ParticleSystem>();
public bool repairNow = false;

private Vector3 localVector;
private Quaternion rot = Quaternion.identity;

private float oldRotation;

//Driving Assistances.
public bool ABS = true;
public bool TCS = true;
public bool ESP = true;
public bool steeringHelper = true;
public bool tractionHelper = true;

public bool ABSAct = false;
public bool TCSAct = false;
public bool ESPAct = false;

[Range(.05f, .5f)]public float ABSThreshold = .35f;
[Range(.05f, .5f)]public float TCSThreshold = .25f;
[Range(0f, 1f)]public float TCSStrength = 1f;
[Range(.05f, .5f)]public float ESPThreshold = .25f;
[Range(.1f, 1f)]public float ESPStrength = .5f;
[Range(0f, 1f)] public float steerHelperStrength = .1f;
[Range(0f, 1f)] public float tractionHelperStrength = .1f;

public bool overSteering = false;
public bool underSteering = false;

// Drift Variables
internal float driftAngle = 0f;
internal bool driftingNow = false;
private bool applyCounterSteering = false;

public float frontCamber = 0f;
public float rearCamber = 0f;

public float frontSlip = 0f;
public float rearSlip = 0f;

float angle;

float angularVelo;

//private WheelCollider anyWheel;
public float turboBoost = 0f;
public float NoS = 100f;
private float NoSConsumption = 25f;
private float NoSRegenerateTime = 10f;

public bool useNOS = false;
public bool useTurbo = false;

void Awake (){

Time.fixedDeltaTime = RCCSettings.fixedTimeStep;

rigid = GetComponent<Rigidbody>();
rigid.maxAngularVelocity = RCCSettings.maxAngularVelocity;
rigid.drag = .05f;
rigid.angularDrag = .5f;

allWheelColliders = GetComponentsInChildren<RCC_WheelCollider>();
//anyWheel = GetComponentInChildren<WheelCollider>();
http://anyWheel.ConfigureVehicleSubsteps(10f, 5, 5);

FrontLeftRCCWheelCollider = FrontLeftWheelCollider.GetComponent<RCC_WheelCollider>();
FrontRightRCCWheelCollider = FrontRightWheelCollider.GetComponent<RCC_WheelCollider>();

FrontLeftWheelCollider.wheelModel = FrontLeftWheelTransform;
FrontRightWheelCollider.wheelModel = FrontRightWheelTransform;
RearLeftWheelCollider.wheelModel = RearLeftWheelTransform;
RearRightWheelCollider.wheelModel = RearRightWheelTransform;

for (int i = 0; i < ExtraRearWheelsCollider.Length; i++) {
ExtraRearWheelsCollider[i].wheelModel = ExtraRearWheelsTransform[i];
}

orgSteerAngle = steerAngle;

allAudioSources = new GameObject("All Audio Sources");
allAudioSources.transform.SetParent(transform, false);

allContactParticles = new GameObject("All Contact Particles");
allContactParticles.transform.SetParent(transform, false);

switch(RCCSettings.behaviorType){

case RCC_Settings.BehaviorType.SemiArcade:
steeringHelper = true;
tractionHelper = true;
ABS = false;
ESP = false;
TCS = false;
steerHelperStrength = Mathf.Clamp(steerHelperStrength, .25f, 1f);
tractionHelperStrength = Mathf.Clamp(tractionHelperStrength, .25f, 1f);
antiRollFrontHorizontal = Mathf.Clamp(antiRollFrontHorizontal, 10000f, Mathf.Infinity);
antiRollRearHorizontal = Mathf.Clamp(antiRollRearHorizontal, 10000f, Mathf.Infinity);
break;

case RCC_Settings.BehaviorType.Drift:
steeringHelper = false;
tractionHelper = false;
ABS = false;
ESP = false;
TCS = false;
highspeedsteerAngle = Mathf.Clamp(highspeedsteerAngle, 40f, 50f);
highspeedsteerAngleAtspeed = Mathf.Clamp(highspeedsteerAngleAtspeed, 100f, maxspeed);
applyCounterSteering = true;
engineTorque = Mathf.Clamp(engineTorque, 5000f, Mathf.Infinity);
antiRollFrontHorizontal = Mathf.Clamp(antiRollFrontHorizontal, 3500f, Mathf.Infinity);
antiRollRearHorizontal = Mathf.Clamp(antiRollRearHorizontal, 3500f, Mathf.Infinity);
gearShiftingDelay = Mathf.Clamp(gearShiftingDelay, 0f, .15f);
break;

case RCC_Settings.BehaviorType.Fun:
steeringHelper = false;
tractionHelper = false;
ABS = false;
ESP = false;
TCS = false;
highspeedsteerAngle = Mathf.Clamp(highspeedsteerAngle, 30f, 50f);
highspeedsteerAngleAtspeed = Mathf.Clamp(highspeedsteerAngleAtspeed, 100f, maxspeed);
antiRollFrontHorizontal = Mathf.Clamp(antiRollFrontHorizontal, 50000f, Mathf.Infinity);
antiRollRearHorizontal = Mathf.Clamp(antiRollRearHorizontal, 50000f, Mathf.Infinity);
gearShiftingDelay = Mathf.Clamp(gearShiftingDelay, 0f, .1f);
break;

case RCC_Settings.BehaviorType.Racing:
steeringHelper = true;
tractionHelper = true;
steerHelperStrength = Mathf.Clamp(steerHelperStrength, .25f, 1f);
tractionHelperStrength = Mathf.Clamp(tractionHelperStrength, .25f, 1f);
antiRollFrontHorizontal = Mathf.Clamp(antiRollFrontHorizontal, 10000f, Mathf.Infinity);
antiRollRearHorizontal = Mathf.Clamp(antiRollRearHorizontal, 10000f, Mathf.Infinity);
break;

case RCC_Settings.BehaviorType.Simulator:
antiRollFrontHorizontal = Mathf.Clamp(antiRollFrontHorizontal, 2500f, Mathf.Infinity);
antiRollRearHorizontal = Mathf.Clamp(antiRollRearHorizontal, 2500f, Mathf.Infinity);
break;

}

}

void Start(){

if(GetComponentAIController = true;

if(autoGenerateGearCurves)
TorqueCurve();

SoundsInitialize();

if(useDamage)
DamageInit();

if(runEngineAtAwake)
KillOrStartEngine();

ChassisJoint();

rigid.centerOfMass = transform.InverseTransformPoint(COM.transform.position);

if(canControl){
if(RCC_Settings.Instance.controllerType == RCC_Settings.ControllerType.Mobile){
GameObject.FindObjectOfType<RCC_MobileButtons>().GetVehicles();
}

if(GameObject.FindObjectOfType<RCC_DashboardInputs>())
GameObject.FindObjectOfType<RCC_DashboardInputs>().GetVehicle(this);
}

}

void OnEnable(){

StartCoroutine("ReEnable");

}

IEnumerator ReEnable(){

if(!chassis.GetComponentInParent<ConfigurableJoint>())
yield return null;

GameObject _joint = chassis.GetComponentInParent<ConfigurableJoint>().gameObject;

_joint.SetActive(false);
yield return new WaitForFixedUpdate();
_joint.SetActive(true);
rigid.centerOfMass = transform.InverseTransformPoint(COM.transform.position);
changingGear = false;

}

public void CreateWheelColliders (){

List <Transform> allWheelModels = new List<Transform>();
allWheelModels.Add(FrontLeftWheelTransform); allWheelModels.Add(FrontRightWheelTransform); allWheelModels.Add(RearLeftWheelTransform); allWheelModels.Add(RearRightWheelTransform);

if(allWheelModels != null && allWheelModels[0] == null){
Debug.LogError("You haven't choose your Wheel Models. Please select all of your Wheel Models before creating Wheel Colliders. Script needs to know their sizes and positions, aye?");
return;
}

transform.rotation = Quaternion.identity;

GameObject WheelColliders = new GameObject("Wheel Colliders");
WheelColliders.transform.SetParent(transform, false);
WheelColliders.transform.localRotation = Quaternion.identity;
WheelColliders.transform.localPosition = Vector3.zero;
WheelColliders.transform.localScale = Vector3.one;

foreach(Transform wheel in allWheelModels){

GameObject wheelcollider = new GameObject(wheel.transform.name);

wheelcollider.transform.position = wheel.transform.position;
wheelcollider.transform.rotation = transform.rotation;
wheelcollider.transform.name = wheel.transform.name;
wheelcollider.transform.SetParent(WheelColliders.transform);
wheelcollider.transform.localScale = Vector3.one;
wheelcollider.AddComponent<WheelCollider>();

Bounds biggestBound = new Bounds();
Renderer[] renderers = wheel.GetComponentsInChildren<Renderer>();

foreach (Renderer render in renderers) {
if (render != GetComponent<Renderer>()){
if(render.bounds.size.z > biggestBound.size.z)
biggestBound = render.bounds;
}
}

wheelcollider.GetComponent<WheelCollider>().radius = (biggestBound.extents.y) / transform.localScale.y;
wheelcollider.AddComponent<RCC_WheelCollider>();
JointSpring spring = wheelcollider.GetComponent<WheelCollider>().suspensionSpring;

spring.spring = 40000f;
spring.damper = 2000f;
spring.targetPosition = .4f;

wheelcollider.GetComponent<WheelCollider>().suspensionSpring = spring;
wheelcollider.GetComponent<WheelCollider>().suspensionDistance = .2f;
wheelcollider.GetComponent<WheelCollider>().forceAppPointDistance = .1f;
wheelcollider.GetComponent<WheelCollider>().mass = 40f;
wheelcollider.GetComponent<WheelCollider>().wheelDampingRate = 1f;

WheelFrictionCurve sidewaysFriction;
WheelFrictionCurve forwardFriction;

sidewaysFriction = wheelcollider.GetComponent<WheelCollider>().sidewaysFriction;
forwardFriction = wheelcollider.GetComponent<WheelCollider>().forwardFriction;

wheelcollider.transform.localPosition = new Vector3(wheelcollider.transform.localPosition.x, wheelcollider.transform.localPosition.y + wheelcollider.GetComponent<WheelCollider>().suspensionDistance, wheelcollider.transform.localPosition.z);

forwardFriction.extremumSlip = .2f;
forwardFriction.extremumValue = 1;
forwardFriction.asymptoteSlip = .8f;
forwardFriction.asymptoteValue = .75f;
forwardFriction.stiffness = 1.5f;

sidewaysFriction.extremumSlip = .25f;
sidewaysFriction.extremumValue = 1;
sidewaysFriction.asymptoteSlip = .5f;
sidewaysFriction.asymptoteValue = .75f;
sidewaysFriction.stiffness = 1.5f;

wheelcollider.GetComponent<WheelCollider>().sidewaysFriction = sidewaysFriction;
wheelcollider.GetComponent<WheelCollider>().forwardFriction = forwardFriction;

}

RCC_WheelCollider[] allWheelColliders = new RCC_WheelCollider[allWheelModels.Count];
allWheelColliders = GetComponentsInChildren<RCC_WheelCollider>();

FrontLeftWheelCollider = allWheelColliders[0];
FrontRightWheelCollider = allWheelColliders[1];
RearLeftWheelCollider = allWheelColliders[2];
RearRightWheelCollider = allWheelColliders[3];

}

void SoundsInitialize (){

engineSoundOn = RCC_CreateAudioSource.NewAudioSource(gameObject, "Engine Sound On AudioSource", 5, 100, 0, engineClipOn, true, true, false);
engineSoundOff = RCC_CreateAudioSource.NewAudioSource(gameObject, "Engine Sound Off AudioSource", 5, 100, 0, engineClipOff, true, true, false);
engineSoundIdle = RCC_CreateAudioSource.NewAudioSource(gameObject, "Engine Sound Idle AudioSource", 5, 100, 0, engineClipIdle, true, true, false);

reversingSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Reverse Sound AudioSource", 5, 10, 0, reversingClip, true, false, false);
windSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Wind Sound AudioSource", 5, 10, 0, windClip, true, true, false);
brakeSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Brake Sound AudioSource", 5, 10, 0, brakeClip, true, true, false);

if(useNOS)
NOSSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "NOS Sound AudioSource", 5, 10, 1f, NOSClip, true, false, false);
if(useNOS || useTurbo)
blowSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "NOS Blow", 3f, 10f, 1f, null, false, false, false);
if(useTurbo){
turboSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Turbo Sound AudioSource", .1f, .5f, 0f, turboClip, true, true, false);
RCC_CreateAudioSource.NewHighPassFilter(turboSound, 10000f, 10);
}

}

public void KillOrStartEngine (){

if(engineRunning && !engineStarting){
engineRunning = false;
fuelInput = 0f;
}else if(!engineStarting){
StartCoroutine("StartEngine");
}

}

public IEnumerator StartEngine (){

engineRunning = false;
engineStarting = true;
engineStartSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Engine Start AudioSource", 5, 10, 1, engineStartClip, false, true, true);
if(engineStartSound.isPlaying)
engineStartSound.Play();
yield return new WaitForSeconds(1f);
engineRunning = true;
fuelInput = 1f;
yield return new WaitForSeconds(1f);
engineStarting = false;

}

void ChassisJoint(){

GameObject colliders = new GameObject("Colliders");
colliders.transform.SetParent(transform, false);

GameObject chassisJoint;

Transform[] childTransforms = chassis.GetComponentsInChildren<Transform>();

foreach(Transform t in childTransforms){

if(t.gameObject.activeSelf && t.GetComponent<Collider>()){

GameObject newGO = (GameObject)Instantiate(t.gameObject, t.transform.position, t.transform.rotation);
newGO.transform.SetParent(colliders.transform, true);
newGO.transform.localScale = t.lossyScale;

Component[] components = newGO.GetComponents(typeof(Component));

foreach(Component comp in components){
if(!(comp is Transform) && !(comp is Collider)){
Destroy(comp);
}
}

}

}

chassisJoint = (GameObject)Instantiate((Resources.Load("RCCAssets/Chassis Joint", typeof(GameObject))), Vector3.zero, Quaternion.identity);
chassisJoint.transform.SetParent(transform, false);
chassisJoint.GetComponent<ConfigurableJoint>().connectedBody = rigid;

chassis.transform.SetParent(chassisJoint.transform, false);

Collider[] collidersInChassis = chassis.GetComponentsInChildren<Collider>();

foreach(Collider c in collidersInChassis){

Destroy(c);

}

switch(RCCSettings.behaviorType){

case RCC_Settings.BehaviorType.Fun:

SoftJointLimit joint = new SoftJointLimit();
joint.limit = -10f;
chassisJoint.GetComponent<ConfigurableJoint>().lowAngularXLimit = joint;
joint.limit = 10f;
chassisJoint.GetComponent<ConfigurableJoint>().linearLimit = joint;
chassisJoint.GetComponent<ConfigurableJoint>().highAngularXLimit = joint;
chassisJoint.GetComponent<ConfigurableJoint>().angularYLimit = joint;
chassisJoint.GetComponent<ConfigurableJoint>().angularZLimit = joint;
JointDrive jointDrive = new JointDrive();
jointDrive.positionSpring = 300f;
jointDrive.positionDamper = 5f;
jointDrive.maximumForce = chassisJoint.GetComponent<ConfigurableJoint>().xDrive.maximumForce;
chassisJoint.GetComponent<ConfigurableJoint>().xDrive = jointDrive;
chassisJoint.GetComponent<ConfigurableJoint>().yDrive = jointDrive;
chassisJoint.GetComponent<ConfigurableJoint>().zDrive = jointDrive;
chassisJoint.GetComponent<ConfigurableJoint>().angularXDrive = jointDrive;
chassisJoint.GetComponent<ConfigurableJoint>().angularYZDrive = jointDrive;
chassisJoint.GetComponent<Rigidbody>().centerOfMass = transform.InverseTransformPoint(new Vector3(chassisJoint.transform.position.x, chassisJoint.transform.position.y + 1f, chassisJoint.transform.position.z));

break;

}

}

void DamageInit (){

if (deformableMeshFilters.Length == 0){

MeshFilter[] allMeshFilters = GetComponentsInChildren<MeshFilter>();
List <MeshFilter> properMeshFilters = new List<MeshFilter>();

foreach(MeshFilter mf in allMeshFilters){
if(!mf.transform.IsChildOf(FrontLeftWheelTransform) && !mf.transform.IsChildOf(FrontRightWheelTransform) && !mf.transform.IsChildOf(RearLeftWheelTransform) && !mf.transform.IsChildOf(RearRightWheelTransform))
properMeshFilters.Add(mf);
}

deformableMeshFilters = properMeshFilters.ToArray();

}

LoadOriginalMeshData();

if(contactSparkle){

for(int i = 0; i < maximumContactSparkle; i++){
GameObject sparks = (GameObject)Instantiate(contactSparkle, transform.position, Quaternion.identity) as GameObject;
sparks.transform.SetParent(allContactParticles.transform);
contactSparkeList.Add(sparks.GetComponentParticleSystem.EmissionModule em = sparks.GetComponent<ParticleSystem>().emission;
em.enabled = false;
}

}

}

void LoadOriginalMeshData(){

originalMeshData = new originalMeshVerts[deformableMeshFilters.Length];

for (int i = 0; i < deformableMeshFilters.Length; i++){
originalMeshData[i].meshVerts = deformableMeshFilters[i].mesh.vertices;
}

}

void Damage(){

if (!sleep && repairNow){

int k;
sleep = true;

for(k = 0; k < deformableMeshFilters.Length; k++){

Vector3[] vertices = deformableMeshFilters[k].mesh.vertices;

if(originalMeshData==null)
LoadOriginalMeshData();

for (int i = 0; i < vertices.Length; i++){

vertices[i] += (originalMeshData[k].meshVerts[i] - vertices[i]) * (Time.deltaTime * 2f);
if((originalMeshData[k].meshVerts[i] - vertices[i]).magnitude >= minimumVertDistanceForDamagedMesh)
sleep = false;

}

deformableMeshFilters[k].mesh.vertices=vertices;
deformableMeshFilters[k].mesh.RecalculateNormals();
deformableMeshFilters[k].mesh.RecalculateBounds();

}

if(sleep)
repairNow = false;

}

}

void DeformMesh(Mesh mesh, Vector3[] originalMesh, Collision collision, float cos, Transform meshTransform, Quaternion rot){

Vector3[] vertices = mesh.vertices;

foreach (ContactPoint contact in collision.contacts){

Vector3 point = meshTransform.InverseTransformPoint(contact.point);

for (int i = 0; i < vertices.Length; i++){

if ((point - vertices[i]).magnitude < damageRadius){
vertices[i] += rot * ((localVector * (damageRadius - (point - vertices[i]).magnitude) / damageRadius) * cos + (UnityEngine.Random.onUnitSphere * (randomizeVertices / 500f)));
if (maximumDamage > 0 && ((vertices[i] - originalMesh[i]).magnitude) > maximumDamage){
vertices[i] = originalMesh[i] + (vertices[i] - originalMesh[i]).normalized * (maximumDamage);
}
}

}

}

mesh.vertices = vertices;
http://mesh.RecalculateNormals();
mesh.RecalculateBounds();
mesh.Optimize();

}

void CollisionParticles(Vector3 contactPoint){

for(int i = 0; i < contactSparkeList.Count; i++){
if(contactSparkeList[i].isPlaying)
return;
contactSparkeList[i].transform.position = contactPoint;
ParticleSystem.EmissionModule em = contactSparkeList[i].emission;
em.enabled = true;
contactSparkeList[i].Play();
}

}

void Update (){

if(canControl){
if(!AIController)
Inputs();
GearBox();
Clutch();
}else if(!AIController){
// _gasInput = 0f;
// brakeInput = 0f;
// boostInput = 1f;
// handbrakeInput = 1f;
}


Turbo();
Sounds();
ResetCar();

if(useDamage)
Damage();

indicatorTimer += Time.deltaTime;

}

void Inputs(){

switch(RCCSettings.controllerType){

case RCC_Settings.ControllerType.Keyboard:

gasInput = Input.GetAxis(RCCSettings.verticalInput);
brakeInput = Mathf.Clamp01(-Input.GetAxis(RCCSettings.verticalInput));
handbrakeInput = Input.GetKey(RCCSettings.handbrakeKB) ? 1f : 0f;
steerInput = Input.GetAxis(RCCSettings.horizontalInput);
boostInput = Input.GetKey(RCCSettings.boostKB) ? 2.5f : 1f;

if(Input.GetKeyDown(RCCSettings.lowBeamHeadlightsKB)){
lowBeamHeadLightsOn = !lowBeamHeadLightsOn;
}

if(Input.GetKeyDown(RCCSettings.highBeamHeadlightsKB)){
highBeamHeadLightsOn = true;
}else if(Input.GetKeyUp(RCCSettings.highBeamHeadlightsKB)){
highBeamHeadLightsOn = false;
}

if(Input.GetKeyDown(RCCSettings.startEngineKB))
KillOrStartEngine();

if(Input.GetKeyDown(RCCSettings.rightIndicatorKB)){
if(indicatorsOn != IndicatorsOn.Right)
indicatorsOn = IndicatorsOn.Right;
else
indicatorsOn = IndicatorsOn.Off;
}

if(Input.GetKeyDown(RCCSettings.leftIndicatorKB)){
if(indicatorsOn != IndicatorsOn.Left)
indicatorsOn = IndicatorsOn.Left;
else
indicatorsOn = IndicatorsOn.Off;
}

if(Input.GetKeyDown(RCCSettings.hazardIndicatorKB)){
if(indicatorsOn != IndicatorsOn.All){
indicatorsOn = IndicatorsOn.Off;
indicatorsOn = IndicatorsOn.All;
}else{
indicatorsOn = IndicatorsOn.Off;
}
}

if(!automaticGear){

if(currentGear < totalGears - 1 && !changingGear){
if(Input.GetKeyDown(RCCSettings.shiftGearUp)){
if(direction != -1)
StartCoroutine("ChangingGear", currentGear + 1);
else
StartCoroutine("ChangingGear", 0);
}
}

if(currentGear >= 0){
if(Input.GetKeyDown(RCCSettings.shiftGearDown)){
StartCoroutine("ChangingGear", currentGear - 1);
}
}

}

break;

}

}

void FixedUpdate (){

Engine();
Braking();
AntiRollBars();
DriftVariables();
RevLimiter();
NOS();
ApplySteering(FrontLeftWheelCollider);
ApplySteering(FrontRightWheelCollider);

if(steeringHelper)
SteerHelper();

if(tractionHelper)
TractionHelper();

if(ESP)
ESPCheck(rigid.angularVelocity.y, FrontLeftWheelCollider.steerAngle);

if(autoGenerateGearCurves)
TorqueCurve();

if(RCCSettings.behaviorType == RCC_Settings.BehaviorType.Drift){

if(RearLeftWheelCollider.isGrounded){
rigid.angularVelocity = new Vector3(rigid.angularVelocity.x, rigid.angularVelocity.y + (direction * steerInput / 30f), rigid.angularVelocity.z);
}

}

if(RCCSettings.behaviorType == RCC_Settings.BehaviorType.SemiArcade || RCCSettings.behaviorType == RCC_Settings.BehaviorType.Fun){

if(RearLeftWheelCollider.isGrounded){
rigid.angularVelocity = new Vector3(rigid.angularVelocity.x, ((direction * (steerInput * Mathf.Lerp(0f, 2f, speed / 20f)))), rigid.angularVelocity.z);
}

}

http://rigid.angularVelocity = new Vector3(rigid.angularVelocity.x, Mathf.Lerp(rigid.angularVelocity.y, ((direction * (steerInput * 2f))), Time.fixedDeltaTime * 10f), rigid.angularVelocity.z);

}

void Engine (){

//Speed.
speed = rigid.velocity.magnitude * 3.6f;

//Steer Limit.
steerAngle = Mathf.Lerp(orgSteerAngle, highspeedsteerAngle, (speed / highspeedsteerAngleAtspeed));

//Driver SteeringWheel Transform.
if(SteeringWheel)
SteeringWheel.transform.rotation = transform.rotation * Quaternion.Euler(20, 0, (FrontLeftWheelCollider.steerAngle) * -6);

if(rigid.velocity.magnitude < .01f && Mathf.Abs(steerInput) < .01f && Mathf.Abs(_gasInput) < .01f && Mathf.Abs(rigid.angularVelocity.magnitude) < .01f)
sleepingRigid = true;
else
sleepingRigid = false;

rawEngineRPM = Mathf.Clamp(Mathf.MoveTowards(rawEngineRPM,
(maxEngineRPM * 1.1f) *
(Mathf.Clamp01(Mathf.Lerp(0f, 1f, (1f - clutchInput) * ((((RearLeftWheelCollider.wheelRPMToSpeed + RearRightWheelCollider.wheelRPMToSpeed) * direction) / 2f) / gearSpeed[currentGear])) + (((_gasInput) * clutchInput) + idleInput) * fuelInput))
, engineInertia * 100f), 0f, maxEngineRPM * 1.1f);

engineRPM = Mathf.Lerp(engineRPM, rawEngineRPM, Mathf.Lerp(Time.fixedDeltaTime * 5f, Time.fixedDeltaTime * 50f, rawEngineRPM / maxEngineRPM));

//Auto Reverse Bool.
if(autoReverse){
canGoReverseNow = true;
}else{
if(_brakeInput < .1f && speed < 5)
canGoReverseNow = true;
else if(_brakeInput > 0 && transform.InverseTransformDirection(rigid.velocity).z > 1f)
canGoReverseNow = false;
}

#region Wheel Type Motor Torque.

//Applying WheelCollider Motor Torques Depends On Wheel Type Choice.
switch(_wheelTypeChoise){

case WheelType.FWD:
ApplyMotorTorque(FrontLeftWheelCollider, engineTorque);
ApplyMotorTorque(FrontRightWheelCollider, engineTorque);
break;
case WheelType.RWD:
ApplyMotorTorque(RearLeftWheelCollider, engineTorque);
ApplyMotorTorque(RearRightWheelCollider, engineTorque);
break;
case WheelType.AWD:
ApplyMotorTorque(FrontLeftWheelCollider, engineTorque / 2f);
ApplyMotorTorque(FrontRightWheelCollider, engineTorque / 2f);
ApplyMotorTorque(RearLeftWheelCollider, engineTorque / 2f);
ApplyMotorTorque(RearRightWheelCollider, engineTorque / 2f);
break;
case WheelType.BIASED:
ApplyMotorTorque(FrontLeftWheelCollider, (engineTorque * (100 - biasedWheelTorque)) / 100f);
ApplyMotorTorque(FrontRightWheelCollider, (engineTorque * (100 - biasedWheelTorque)) / 100f);
ApplyMotorTorque(RearLeftWheelCollider, (engineTorque * biasedWheelTorque) / 100f);
ApplyMotorTorque(RearRightWheelCollider, (engineTorque * biasedWheelTorque) / 100f);
break;

}

if(ExtraRearWheelsCollider.Length > 0 && applyEngineTorqueToExtraRearWheelColliders){

for(int i = 0; i < ExtraRearWheelsCollider.Length; i++){
ApplyMotorTorque(ExtraRearWheelsCollider[i], engineTorque);
}

}

#endregion Wheel Type

}

void Sounds(){

windSound.volume = Mathf.Lerp (0f, RCCSettings.maxWindSoundVolume, speed / 300f);
windSound.pitch = UnityEngine.Random.Range(.9f, 1f);

if(direction == 1)
brakeSound.volume = Mathf.Lerp (0f, RCCSettings.maxBrakeSoundVolume, Mathf.Clamp01((FrontLeftWheelCollider.wheelCollider.brakeTorque + FrontRightWheelCollider.wheelCollider.brakeTorque) / (brake * 2f)) * Mathf.Lerp(0f, 1f, FrontLeftWheelCollider.rpm / 50f));
else
brakeSound.volume = 0f;

}

void ApplyMotorTorque(RCC_WheelCollider wc, float torque){

if(TCS){

WheelHit hit;
wc.wheelCollider.GetGroundHit(out hit);

if(Mathf.Abs(wc.rpm) >= 100){
if(hit.forwardSlip > .25f){
TCSAct = true;
torque -= Mathf.Clamp(torque * (hit.forwardSlip) * TCSStrength, 0f, engineTorque);
}else{
TCSAct = false;
torque += Mathf.Clamp(torque * (hit.forwardSlip) * TCSStrength, -engineTorque, 0f);
}
}else{
TCSAct = false;
}

}

if(OverTorque())
torque = 0;

wc.wheelCollider.motorTorque = ((torque * (1 - clutchInput) * _boostInput) * _gasInput) * (engineTorqueCurve[currentGear].Evaluate(wc.wheelRPMToSpeed * direction) * direction);

ApplyEngineSound(wc.wheelCollider.motorTorque);

}

void ESPCheck(float velocity, float steering){

WheelHit frontHit1;
FrontLeftWheelCollider.wheelCollider.GetGroundHit(out frontHit1);

WheelHit frontHit2;
FrontRightWheelCollider.wheelCollider.GetGroundHit(out frontHit2);

frontSlip = frontHit1.sidewaysSlip + frontHit2.sidewaysSlip;

WheelHit rearHit1;
RearLeftWheelCollider.wheelCollider.GetGroundHit(out rearHit1);

WheelHit rearHit2;
RearRightWheelCollider.wheelCollider.GetGroundHit(out rearHit2);

rearSlip = rearHit1.sidewaysSlip + rearHit2.sidewaysSlip;

if(Mathf.Abs(frontSlip) >= ESPThreshold)
overSteering = true;
else
overSteering = false;

if(Mathf.Abs(rearSlip) >= ESPThreshold && !overSteering)
underSteering = true;
else
underSteering = false;

if(underSteering || overSteering)
ESPAct = true;
else
ESPAct = false;

if(Mathf.Abs(frontSlip) < ESPThreshold || Math.Abs(rearSlip) < ESPThreshold)
return;

if(underSteering){
ApplyBrakeTorque(RearLeftWheelCollider, (brake * ESPStrength) * Mathf.Clamp(frontSlip, 0f, Mathf.Infinity));
ApplyBrakeTorque(RearRightWheelCollider, (brake * ESPStrength) * Mathf.Clamp(-frontSlip, 0f, Mathf.Infinity));
}

if(overSteering){
ApplyBrakeTorque(FrontLeftWheelCollider, (brake * ESPStrength) * Mathf.Clamp(-rearSlip, 0f, Mathf.Infinity));
ApplyBrakeTorque(FrontRightWheelCollider, (brake * ESPStrength) * Mathf.Clamp(rearSlip, 0f, Mathf.Infinity));
}

}

void ApplyBrakeTorque(RCC_WheelCollider wc, float brake){

if(ABS && handbrakeInput <= .1f){

WheelHit hit;
wc.wheelCollider.GetGroundHit(out hit);

if((Mathf.Abs(hit.forwardSlip) * Mathf.Clamp01(brake)) >= ABSThreshold){
ABSAct = true;
brake = 0;
}else{
ABSAct = false;
}

}

wc.wheelCollider.brakeTorque = brake;

}

void ApplySteering(RCC_WheelCollider wc){

if(applyCounterSteering)
wc.wheelCollider.steerAngle = Mathf.Clamp((steerAngle * (steerInput + driftAngle)), -steerAngle, steerAngle);
else
wc.wheelCollider.steerAngle = Mathf.Clamp((steerAngle * steerInput), -steerAngle, steerAngle);

}

void ApplyEngineSound(float input){

if(!engineRunning){

engineSoundOn.pitch = Mathf.Lerp ( engineSoundOn.pitch, 0, Time.deltaTime * 50f);
engineSoundOff.pitch = Mathf.Lerp ( engineSoundOff.pitch, 0, Time.deltaTime * 50f);
engineSoundIdle.pitch = Mathf.Lerp ( engineSoundOff.pitch, 0, Time.deltaTime * 50f);

if(engineSoundOn.pitch <= .1f && engineSoundOff.pitch <= .1f && engineSoundIdle.pitch <= .1f){
engineSoundOn.Stop();
engineSoundOff.Stop();
engineSoundIdle.Stop();
return;
}

}else{

if(!engineSoundOn.isPlaying)
engineSoundOn.Play();
if(!engineSoundOff.isPlaying)
engineSoundOff.Play();
if(!engineSoundIdle.isPlaying)
engineSoundIdle.Play();

}

if(engineSoundOn){

engineSoundOn.volume = _gasInput;
engineSoundOn.pitch = Mathf.Lerp ( engineSoundOn.pitch, Mathf.Lerp (minEngineSoundPitch, maxEngineSoundPitch, engineRPM / 7000f), Time.deltaTime * 50f);

}

if(engineSoundOff){

engineSoundOff.volume = (1 - _gasInput) - engineSoundIdle.volume;
engineSoundOff.pitch = Mathf.Lerp ( engineSoundOff.pitch, Mathf.Lerp (minEngineSoundPitch, maxEngineSoundPitch, (engineRPM) / (7000f)), Time.deltaTime * 50f);

}

if(engineSoundIdle){

engineSoundIdle.volume = Mathf.Lerp(1f, 0f, engineRPM / (maxEngineRPM / 2f));
engineSoundIdle.pitch = Mathf.Lerp ( engineSoundIdle.pitch, Mathf.Lerp (minEngineSoundPitch, maxEngineSoundPitch, (engineRPM) / (7000f)), Time.deltaTime * 50f);

}

}

void Braking (){

//Handbrake
if(handbrakeInput > .1f){

ApplyBrakeTorque(RearLeftWheelCollider, (brake * 1.5f) * handbrakeInput);
ApplyBrakeTorque(RearRightWheelCollider, (brake * 1.5f) * handbrakeInput);

}else{

// Braking.
ApplyBrakeTorque(FrontLeftWheelCollider, brake * (Mathf.Clamp(_brakeInput, 0, 1)));
ApplyBrakeTorque(FrontRightWheelCollider, brake * (Mathf.Clamp(_brakeInput, 0, 1)));
ApplyBrakeTorque(RearLeftWheelCollider, brake * Mathf.Clamp(_brakeInput, 0, 1) / 2f);
ApplyBrakeTorque(RearRightWheelCollider, brake * Mathf.Clamp(_brakeInput, 0, 1) / 2f);

}

}

void AntiRollBars (){

#region Horizontal

WheelHit FrontWheelHit;

float travelFL = 1.0f;
float travelFR = 1.0f;

bool groundedFL= FrontLeftWheelCollider.wheelCollider.GetGroundHit(out FrontWheelHit);

if (groundedFL)
travelFL = (-FrontLeftWheelCollider.transform.InverseTransformPoint(FrontWheelHit.point).y - FrontLeftWheelCollider.wheelCollider.radius) / FrontLeftWheelCollider.wheelCollider.suspensionDistance;

bool groundedFR= FrontRightWheelCollider.wheelCollider.GetGroundHit(out FrontWheelHit);

if (groundedFR)
travelFR = (-FrontRightWheelCollider.transform.InverseTransformPoint(FrontWheelHit.point).y - FrontRightWheelCollider.wheelCollider.radius) / FrontRightWheelCollider.wheelCollider.suspensionDistance;

float antiRollForceFrontHorizontal= (travelFL - travelFR) * antiRollFrontHorizontal;

if (groundedFL)
rigid.AddForceAtPosition(FrontLeftWheelCollider.transform.up * -antiRollForceFrontHorizontal, FrontLeftWheelCollider.transform.position);
if (groundedFR)
rigid.AddForceAtPosition(FrontRightWheelCollider.transform.up * antiRollForceFrontHorizontal, FrontRightWheelCollider.transform.position);

WheelHit RearWheelHit;

float travelRL = 1.0f;
float travelRR = 1.0f;

bool groundedRL= RearLeftWheelCollider.wheelCollider.GetGroundHit(out RearWheelHit);

if (groundedRL)
travelRL = (-RearLeftWheelCollider.transform.InverseTransformPoint(RearWheelHit.point).y - RearLeftWheelCollider.wheelCollider.radius) / RearLeftWheelCollider.wheelCollider.suspensionDistance;

bool groundedRR= RearRightWheelCollider.wheelCollider.GetGroundHit(out RearWheelHit);

if (groundedRR)
travelRR = (-RearRightWheelCollider.transform.InverseTransformPoint(RearWheelHit.point).y - RearRightWheelCollider.wheelCollider.radius) / RearRightWheelCollider.wheelCollider.suspensionDistance;

float antiRollForceRearHorizontal= (travelRL - travelRR) * antiRollRearHorizontal;

if (groundedRL)
rigid.AddForceAtPosition(RearLeftWheelCollider.transform.up * -antiRollForceRearHorizontal, RearLeftWheelCollider.transform.position);
if (groundedRR)
rigid.AddForceAtPosition(RearRightWheelCollider.transform.up * antiRollForceRearHorizontal, RearRightWheelCollider.transform.position);

#endregion

#region Vertical

float antiRollForceFrontVertical= (travelFL - travelRL) * antiRollVertical;

if (groundedFL)
rigid.AddForceAtPosition(FrontLeftWheelCollider.transform.up * -antiRollForceFrontVertical, FrontLeftWheelCollider.transform.position);
if (groundedRL)
rigid.AddForceAtPosition(RearLeftWheelCollider.transform.up * antiRollForceFrontVertical, RearLeftWheelCollider.transform.position);

float antiRollForceRearVertical= (travelFR - travelRR) * antiRollVertical;

if (groundedFR)
rigid.AddForceAtPosition(FrontRightWheelCollider.transform.up * -antiRollForceRearVertical, FrontRightWheelCollider.transform.position);
if (groundedRR)
rigid.AddForceAtPosition(RearRightWheelCollider.transform.up * antiRollForceRearVertical, RearRightWheelCollider.transform.position);

#endregion

}

void SteerHelper(){

for (int i = 0; i < allWheelColliders.Length; i++){

WheelHit hit;
allWheelColliders[i].wheelCollider.GetGroundHit(out hit);
if (hit.normal == Vector3.zero)
return;

}

if (Mathf.Abs(oldRotation - transform.eulerAngles.y) < 10f){

float turnadjust = (transform.eulerAngles.y - oldRotation) * steerHelperStrength;
Quaternion velRotation = Quaternion.AngleAxis(turnadjust, Vector3.up);
rigid.velocity = (velRotation * rigid.velocity);

}

oldRotation = transform.eulerAngles.y;

}

void TractionHelper(){

Vector3 velocity =rigid.velocity;
velocity -= transform.up * Vector3.Dot(velocity, transform.up);
velocity.Normalize();

angle = -Mathf.Asin(Vector3.Dot(Vector3.Cross(transform.forward, velocity), transform.up));

angularVelo = rigid.angularVelocity.y;

if (angle * FrontLeftWheelCollider.steerAngle < 0)
FrontLeftRCCWheelCollider.tractionHelpedSidewaysStiffness = (1f - Mathf.Clamp01(tractionHelperStrength * Mathf.Abs(angularVelo)));
else
FrontLeftRCCWheelCollider.tractionHelpedSidewaysStiffness = 1f;

if (angle * FrontRightWheelCollider.steerAngle < 0)
FrontRightRCCWheelCollider.tractionHelpedSidewaysStiffness = (1f - Mathf.Clamp01(tractionHelperStrength * Mathf.Abs(angularVelo)));
else
FrontRightRCCWheelCollider.tractionHelpedSidewaysStiffness = 1f;

}

void Clutch(){

if(speed <= 10f && !cutGas){

clutchInput = Mathf.Lerp(clutchInput, (Mathf.Lerp(1f, (Mathf.Lerp(.2f, 0f, ((RearLeftWheelCollider.wheelRPMToSpeed + RearRightWheelCollider.wheelRPMToSpeed) / 2f) / (10))), Mathf.Abs(_gasInput))), Time.deltaTime * 50f);

}else if(!cutGas){

if(changingGear)
clutchInput = Mathf.Lerp(clutchInput, 1, Time.deltaTime * 10f);
else
clutchInput = Mathf.Lerp(clutchInput, 0, Time.deltaTime * 10f);

}

if(cutGas || handbrakeInput >= .1f)
clutchInput = 1f;

clutchInput = Mathf.Clamp01(clutchInput);

}

void GearBox (){

if(engineRunning)
idleInput = Mathf.Lerp(1f, 0f, engineRPM / minEngineRPM);
else
idleInput = 0f;

//Reversing Bool.
if(!AIController){
if(brakeInput > .9f && transform.InverseTransformDirection(rigid.velocity).z < 1f && canGoReverseNow && automaticGear && !semiAutomaticGear && !changingGear && direction != -1)
StartCoroutine("ChangingGear", -1);
else if(brakeInput < .1f && transform.InverseTransformDirection(rigid.velocity).z > -1f && direction == -1 && !changingGear && automaticGear && !semiAutomaticGear)
StartCoroutine("ChangingGear", 0);
}

if(automaticGear){

if(currentGear < totalGears - 1 && !changingGear){
if(speed >= (gearSpeed[currentGear] * .7f) && FrontLeftWheelCollider.rpm > 0){
if(!semiAutomaticGear)
StartCoroutine("ChangingGear", currentGear + 1);
else if(semiAutomaticGear && direction != -1)
StartCoroutine("ChangingGear", currentGear + 1);
}
}

if(currentGear > 0){

if(!changingGear){

if(speed < (gearSpeed[currentGear - 1] * .5f) && direction != -1){
StartCoroutine("ChangingGear", currentGear - 1);
}

}

}

}

if(direction == -1){
if(!reversingSound.isPlaying)
reversingSound.Play();
reversingSound.volume = Mathf.Lerp(0f, 1f, speed / 60f);
reversingSound.pitch = reversingSound.volume;
}else{
if(reversingSound.isPlaying)
reversingSound.Stop();
reversingSound.volume = 0f;
reversingSound.pitch = 0f;
}

}

internal IEnumerator ChangingGear(int gear){

changingGear = true;

if(RCCSettings.useTelemetry)
print ("Shifted to: " + (gear).ToString());

if(gearShiftingClips.Length > 0){
gearShiftingSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Gear Shifting AudioSource", 5, 5, RCCSettings.maxGearShiftingSoundVolume, gearShiftingClips[UnityEngine.Random.Range(0, gearShiftingClips.Length)], false, true, true);
if(!gearShiftingSound.isPlaying)
gearShiftingSound.Play();
}

yield return new WaitForSeconds(gearShiftingDelay);

if(gear == -1){
currentGear = 0;
direction = -1;
}else{
currentGear = gear;
direction = 1;
}

changingGear = false;

}

void RevLimiter(){

if((useRevLimiter && engineRPM >= maxEngineRPM * 1.05f))
cutGas = true;
else if(engineRPM < maxEngineRPM)
cutGas = false;

}

void NOS(){

if(!useNOS)
return;

if(boostInput > 1.5f && _gasInput >= .8f && NoS > 5){
NoS -= NoSConsumption * Time.deltaTime;
NoSRegenerateTime = 0f;
if(!NOSSound.isPlaying)
NOSSound.Play();
}else{
if(NoS < 100 && NoSRegenerateTime > 3)
NoS += (NoSConsumption / 1.5f) * Time.deltaTime;
NoSRegenerateTime += Time.deltaTime;
if(NOSSound.isPlaying){
NOSSound.Stop();
blowSound.clip = RCCSettings.blowoutClip[UnityEngine.Random.Range(0, RCCSettings.blowoutClip.Length)];
blowSound.Play();
}
}

}

void Turbo(){

if(!useTurbo)
return;

turboBoost = Mathf.Lerp(turboBoost, Mathf.Clamp(Mathf.Pow(_gasInput, 10) * 30f + Mathf.Pow(engineRPM / maxEngineRPM, 10) * 30f, 0f, 30f), Time.deltaTime * 10f);

if(turboBoost >= 25f){
if(turboBoost < (turboSound.volume * 30f)){
if(!blowSound.isPlaying){
blowSound.clip = RCCSettings.blowoutClip[UnityEngine.Random.Range(0, RCCSettings.blowoutClip.Length)];
blowSound.Play();
}
}
}

turboSound.volume = Mathf.Lerp(turboSound.volume, turboBoost / 30f, Time.deltaTime * 5f);
turboSound.pitch = Mathf.Lerp(Mathf.Clamp(turboSound.pitch, 2f, 3f), (turboBoost / 30f) * 2f, Time.deltaTime * 5f);


}

void DriftVariables(){

WheelHit hit;
RearRightWheelCollider.wheelCollider.GetGroundHit(out hit);

if(speed > 1f && driftingNow)
driftAngle = hit.sidewaysSlip * 1f;
else
driftAngle = 0f;

if(Mathf.Abs(hit.sidewaysSlip) > .25f)
driftingNow = true;
else
driftingNow = false;

}

void ResetCar (){

if(speed < 5 && !rigid.isKinematic){

if(transform.eulerAngles.z < 300 && transform.eulerAngles.z > 60){
resetTime += Time.deltaTime;
if(resetTime > 3){
transform.rotation = Quaternion.identity;
transform.position = new Vector3(transform.position.x, transform.position.y + 3, transform.position.z);
resetTime = 0f;
}
}

}

}

void OnCollisionEnter (Collision collision){

if (collision.contacts.Length < 1 || collision.relativeVelocity.magnitude < minimumCollisionForce)
return;

if(crashClips.Length > 0){
if (collision.contacts[0].thisCollider.gameObject.transform != transform.parent){
crashSound = RCC_CreateAudioSource.NewAudioSource(gameObject, "Crash Sound AudioSource", 5, 20, RCCSettings.maxCrashSoundVolume, crashClips[UnityEngine.Random.Range(0, crashClips.Length)], false, true, true);
if(!crashSound.isPlaying)
crashSound.Play();
}
}

if(useDamage){

CollisionParticles(collision.contacts[0].point);

Vector3 colRelVel = collision.relativeVelocity;
colRelVel *= 1f - Mathf.Abs(Vector3.Dot(transform.up,collision.contacts[0].normal));

float cos = Mathf.Abs(Vector3.Dot(collision.contacts[0].normal, colRelVel.normalized));

if (colRelVel.magnitude * cos >= minimumCollisionForce){

sleep = false;

localVector = transform.InverseTransformDirection(colRelVel) * (damageMultiplier / 50f);

if (originalMeshData == null)
LoadOriginalMeshData();

for (int i = 0; i < deformableMeshFilters.Length; i++){
DeformMesh(deformableMeshFilters[i].mesh, originalMeshData[i].meshVerts, collision, cos, deformableMeshFilters[i].transform, rot);
}

}

}

if(GameObject.FindObjectOfTypeif(GameObject.FindObjectOfType<RCC_Camera>().playerCar == transform)
GameObject.FindObjectOfType<RCC_Camera>().Collision(collision);
}

}

void OnGUI (){

if(RCCSettings.useTelemetry && canControl){

GUI.skin.label.fontSize = 12;
GUI.skin.box.fontSize = 12;

GUI.backgroundColor = Color.gray;
float guiWidth = Screen.width / 2f;

GUI.Box(new Rect(Screen.width - 400 - guiWidth, 10, 800, 270), "");

GUI.Label(new Rect(Screen.width - 390 - guiWidth, 10, 400, 150), "Engine RPM : " + Mathf.CeilToInt(engineRPM));
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 10, 400, 150), "Engine Running : " + (engineRunning == true ? "Running" : "Stopped").ToString());
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 30, 400, 150), "Engine Starter : " + (engineStarting == true ? "Starting" : "Stopped").ToString());

GUI.Label(new Rect(Screen.width - 200 - guiWidth, 90, 400, 150), "Engine Sound On Volume: " + engineSoundOn.volume.ToString("F1"));
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 110, 400, 150), "Engine Sound On Pitch: " + engineSoundOn.pitch.ToString("F1"));
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 130, 400, 150), "Engine Sound Off Volume: " + engineSoundOff.volume.ToString("F1"));
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 150, 400, 150), "Engine Sound Off Pitch: " + engineSoundOff.pitch.ToString("F1"));



GUI.Label(new Rect(Screen.width - 390 - guiWidth, 30, 400, 150), "Speed " + (RCCSettings.units == RCC_Settings.Units.KMH ? "(KM/H)" : "(MP/H)") + Mathf.CeilToInt(speed));
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 50, 400, 150), "Steer Angle : " + Mathf.CeilToInt(FrontLeftWheelCollider.steerAngle));
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 70, 400, 150), "Automatic Shifting : " + (automaticGear == true ? "Automatic" : "Manual").ToString());

// if(!changingGear)
// GUI.Label(new Rect(Screen.width - 390 - guiWidth, 90, 400, 150), "Gear No : " + (direction != -1 ? (currentGear + 1).ToString() : "R").ToString());
if(!changingGear)
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 90, 400, 150), "Gear No : " + (direction == 1 ? ((currentGear + 1).ToString()) : "R"));
else
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 90, 400, 150), "Gear No : " + "N");

GUI.Label(new Rect(Screen.width - 390 - guiWidth, 230, 400, 150), "Mobile Horizontal Tilt : " + Input.acceleration.x);
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 250, 400, 150), "Mobile Vertical Tilt : " + Input.acceleration.y);

//Front Wheels
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 10, 400, 150), "Front Left Wheel RPM : " + Mathf.CeilToInt(FrontLeftWheelCollider.rpm));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 10, 400, 150), "Front Right Wheel RPM : " + Mathf.CeilToInt(FrontRightWheelCollider.rpm));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 30, 400, 150), "Front Left Wheel Torque : " + Mathf.CeilToInt(FrontLeftWheelCollider.wheelCollider.motorTorque));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 30, 400, 150), "Front Right Wheel Torque : " + Mathf.CeilToInt(FrontRightWheelCollider.wheelCollider.motorTorque));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 50, 400, 150), "Front Left Wheel brake : " + Mathf.CeilToInt(FrontLeftWheelCollider.wheelCollider.brakeTorque));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 50, 400, 150), "Front Right Wheel brake : " + Mathf.CeilToInt(FrontRightWheelCollider.wheelCollider.brakeTorque));

WheelHit hit;
FrontLeftWheelCollider.wheelCollider.GetGroundHit(out hit);

http://GUI.Label(new Rect(Screen.width - 200 - guiWidth, 190, 400, 150), "Speed: " + speed);
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 210, 400, 150), "WCSpeed: " + RearLeftWheelCollider.wheelRPMToSpeed);
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 230, 400, 150), "UnderSteer: " + overSteering);
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 250, 400, 150), "OverSteer: " + underSteering);

if(FrontLeftWheelCollider.wheelCollider.GetGroundHit(out hit)){
http://GUI.Label(new Rect(Screen.width - 200 - guiWidth, 50, 400, 150), "Ground Material : " + _groundMaterial.ToString());
GUI.Label(new Rect(Screen.width - 200 - guiWidth, 70, 400, 150), "Ground Grip : " + FrontLeftWheelCollider.forwardFrictionCurve.stiffness);
}
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 70, 400, 150), "Front Left Wheel Force : " + Mathf.CeilToInt(hit.force));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 90, 400, 150), "Front Left Wheel Sideways Grip : " + (1 - Mathf.Abs(hit.sidewaysSlip)).ToString("F2"));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 110, 400, 150), "Front Left Wheel Forward Grip : " + (1 - Mathf.Abs(hit.forwardSlip)).ToString("F2"));

FrontRightWheelCollider.wheelCollider.GetGroundHit(out hit);

GUI.Label(new Rect(Screen.width + 200 - guiWidth, 70, 400, 150), "Front Right Wheel Force : " + Mathf.CeilToInt(hit.force));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 90, 400, 150), "Front Right Wheel Sideways Grip : " + (1 - Mathf.Abs(hit.sidewaysSlip)).ToString("F2"));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 110, 400, 150), "Front Right Wheel Forward Grip : " +(1 - Mathf.Abs(hit.forwardSlip)).ToString("F2"));

GUI.Label(new Rect(Screen.width - 390 - guiWidth, 170, 400, 150), "ABS: " + ABS + ". Current State: " + (ABSAct == true ? "Engaged" : "Safe").ToString());
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 190, 400, 150), "TCS: " + TCS + ". Current State: " + (TCSAct == true ? "Engaged" : "Safe").ToString());
GUI.Label(new Rect(Screen.width - 390 - guiWidth, 210, 400, 150), "ESP: " + ESP + ". Current State: " + (ESPAct == true ? "Engaged" : "Safe").ToString());

//Rear Wheels
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 150, 400, 150), "Rear Left Wheel RPM : " + Mathf.CeilToInt(RearLeftWheelCollider.rpm));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 150, 400, 150), "Rear Right Wheel RPM : " + Mathf.CeilToInt(RearRightWheelCollider.rpm));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 170, 400, 150), "Rear Left Wheel Torque : " + Mathf.CeilToInt(RearLeftWheelCollider.wheelCollider.motorTorque));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 170, 400, 150), "Rear Right Wheel Torque : " + Mathf.CeilToInt(RearRightWheelCollider.wheelCollider.motorTorque));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 190, 400, 150), "Rear Left Wheel brake : " + Mathf.CeilToInt(RearLeftWheelCollider.wheelCollider.brakeTorque));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 190, 400, 150), "Rear Right Wheel brake : " + Mathf.CeilToInt(RearRightWheelCollider.wheelCollider.brakeTorque));

RearLeftWheelCollider.wheelCollider.GetGroundHit(out hit);

GUI.Label(new Rect(Screen.width + 00 - guiWidth, 210, 400, 150), "Rear Left Wheel Force : " + Mathf.CeilToInt(hit.force));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 230, 400, 150), "Rear Left Wheel Sideways Grip : " + (1 - Mathf.Abs(hit.sidewaysSlip)).ToString("F2"));
GUI.Label(new Rect(Screen.width + 00 - guiWidth, 250, 400, 150), "Rear Left Wheel Forward Grip : " + (1 - Mathf.Abs(hit.forwardSlip)).ToString("F2"));

RearRightWheelCollider.wheelCollider.GetGroundHit(out hit);

GUI.Label(new Rect(Screen.width + 200 - guiWidth, 210, 400, 150), "Rear Right Wheel Force : " + Mathf.CeilToInt(hit.force));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 230, 400, 150), "Rear Right Wheel Sideways Grip : " + (1 - Mathf.Abs(hit.sidewaysSlip)).ToString("F2"));
GUI.Label(new Rect(Screen.width + 200 - guiWidth, 250, 400, 150), "Rear Right Wheel Forward Grip : " + (1 - Mathf.Abs(hit.forwardSlip)).ToString("F2"));

GUI.backgroundColor = Color.green;
GUI.Button (new Rect(Screen.width-20 - guiWidth, 260, 10, Mathf.Clamp((-_gasInput * 100), -100, 0)), "");

GUI.backgroundColor = Color.red;
GUI.Button (new Rect(Screen.width-35 - guiWidth, 260, 10, Mathf.Clamp((-_brakeInput * 100), -100, 0)), "");

GUI.backgroundColor = Color.blue;
GUI.Button (new Rect(Screen.width-50 - guiWidth, 260, 10, Mathf.Clamp((-clutchInput * 100), -100, 0)), "");

}

}

bool OverTorque(){

if(speed > maxspeed || !engineRunning)
return true;

return false;

}

void OnDrawGizmos(){
#if UNITY_EDITOR
if(Application.isPlaying){

WheelHit hit;

for(int i = 0; i < allWheelColliders.Length; i++){

allWheelColliders[i].wheelCollider.GetGroundHit(out hit);

Matrix4x4 temp = Gizmos.matrix;
Gizmos.matrix = Matrix4x4.TRS(allWheelColliders[i].transform.position, Quaternion.AngleAxis(-90, Vector3.right), Vector3.one);
Gizmos.color = new Color((hit.force / rigid.mass) / 5f, (-hit.force / rigid.mass) / 5f, 0f);
Gizmos.DrawFrustum(Vector3.zero, 2f, hit.force / rigid.mass, .1f, 1f);
Gizmos.matrix = temp;

}

}
#endif
}

public void TorqueCurve (){

if(defMaxSpeed != maxspeed){

if(totalGears < 1){
Debug.LogError("You are trying to set your vehicle gear to 0 or below! Why you trying to do this???");
totalGears = 1;
return;
}

gearSpeed = new float[totalGears];
engineTorqueCurve = new AnimationCurve[totalGears];
currentGear = 0;

for(int i = 0; i < engineTorqueCurve.Length; i ++){
engineTorqueCurve[i] = new AnimationCurve(new Keyframe(0, 1));
}

for(int i = 0; i < totalGears; i ++){

gearSpeed[i] = Mathf.Lerp(0, maxspeed, ((float)(i+1)/(float)(totalGears)));

if(i != 0){
engineTorqueCurve[i].MoveKey(0, new Keyframe(0, Mathf.Lerp (.25f, 0, (float)(i+1) / (float)totalGears)));
engineTorqueCurve[i].AddKey(Mathf.Lerp(0, maxspeed / 1f, ((float)(i)/(float)(totalGears))), Mathf.Lerp(1f, .25f, ((float)(i)/(float)(totalGears))));
engineTorqueCurve[i].AddKey(gearSpeed[i], .1f);
engineTorqueCurve[i].AddKey(gearSpeed[i] * 2f, -3f);
engineTorqueCurve[i].postWrapMode = WrapMode.Clamp;
}else{
engineTorqueCurve[i].MoveKey(0, new Keyframe(0, 1));
engineTorqueCurve[i].AddKey(Mathf.Lerp (0, maxspeed / 1f, (float)(i+1) / (float)totalGears), 1f);
engineTorqueCurve[i].AddKey(Mathf.Lerp(25, maxspeed / 1f, ((float)(i+1) / (float)(totalGears))), 0f);
engineTorqueCurve[i].postWrapMode = WrapMode.Clamp;
}

}

}

defMaxSpeed = maxspeed;

}

void OnDisable(){

if(canControl){
if(gameObject.GetComponentInChildrengameObject.GetComponentInChildren<RCC_Camera>().transform.SetParent(null);
}

}

}

O problema é que agr o mesh.optimize nao funciona como faço a mesma funcao nas novas versoes do unity para tirar esse erro?

Obrigado pela atenção e flw


Última edição por dstaroski em Qui Jan 18, 2018 1:04 pm, editado 1 vez(es) (Motivo da edição : Corrigido erro de português)
fabriciorsz34
fabriciorsz34
Avançado
Avançado

PONTOS : 3090
REPUTAÇÃO : 25
Idade : 24
Áreas de atuação : C#,unity,cinema 4D, SketchUp

Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por fabriciorsz34 Qua Jan 17, 2018 9:17 pm

Putz isso aki ficou grande hein
fabriciorsz34
fabriciorsz34
Avançado
Avançado

PONTOS : 3090
REPUTAÇÃO : 25
Idade : 24
Áreas de atuação : C#,unity,cinema 4D, SketchUp

Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por dstaroski Qua Jan 17, 2018 9:23 pm

Boa noite! dá uma olhadinha aqui: https://docs.unity3d.com/ScriptReference/MeshUtility.Optimize.html

Abraço!
dstaroski
dstaroski
Instrutor

Masculino PONTOS : 6052
REPUTAÇÃO : 1123
Idade : 34
Áreas de atuação : Teologia, Unity 3D, C#, HTML, CSS, Dart, Flutter.

Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar Aad8pUi

http://diegodeoliveira.gamejolt.io/defeattheilluminatis

Ir para o topo Ir para baixo

DÚVIDA Re: [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por fabriciorsz34 Qua Jan 17, 2018 10:33 pm

Ah mas essa explicacao ta em js como façi em c# q é o formato do meu arquivo?
fabriciorsz34
fabriciorsz34
Avançado
Avançado

PONTOS : 3090
REPUTAÇÃO : 25
Idade : 24
Áreas de atuação : C#,unity,cinema 4D, SketchUp

Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por Phph09 Qui Jan 18, 2018 8:42 am

Tente assim:


Código:
void Start () {
 Mesh mesh = GetComponent<MeshFilter>().mesh;

 MeshUtility.Optimize(mesh);
 }


Phph09
Phph09
Profissional
Profissional

Masculino PONTOS : 3541
REPUTAÇÃO : 240
Idade : 18
Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por fabriciorsz34 Qui Jan 18, 2018 11:59 am

Entao mano é q a linha de erro ta em outra void vai continuar funcionando do mesmo jeito assim?
fabriciorsz34
fabriciorsz34
Avançado
Avançado

PONTOS : 3090
REPUTAÇÃO : 25
Idade : 24
Áreas de atuação : C#,unity,cinema 4D, SketchUp

Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar

Mensagem por MarcosSchultz Qui Jan 18, 2018 5:09 pm

É só baixar a versão mais atual do Realistic Car Controller... ele ajeitou lá
MarcosSchultz
MarcosSchultz
Administrador

Masculino PONTOS : 64727
REPUTAÇÃO : 2650
Idade : 27
Áreas de atuação : Administrador do fórum
Respeito as regras : [DÚVIDA]Ajuda para como fazer esse script voltar a funcionar Aad8pUi

https://www.schultzgames.com

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos