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:
Procuro freelancer
Novo Teaser do jogo Dark Age
Unity Admob Erro
Mais Um jogo!
DEATH ISLAND 0.2.5 SURVIVAL GAME 4 ANOS EM DESENVOLVIMENTO
Player travando na colisão com o chão Unity 2D
Sombras estão quadradas na build
nao consigo fazer o player sentar no sofa alguem me ajuda
Unity - Ao mudar de scene, todas as Lights são deletadas
210 Linhas de código para inimigo é muito grande?
modelar avatar e skins para um jogo web
Collider (mesh?)
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
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
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
Qui Abr 25, 2024 3:34 pm
Seg Abr 22, 2024 5:15 pm
Seg Abr 15, 2024 12:23 pm
Sáb Abr 13, 2024 11:37 am
Qua Abr 10, 2024 1:33 am
Ter Abr 09, 2024 10:28 am
Seg Abr 08, 2024 9:27 pm
Seg Abr 08, 2024 8:01 am
Sáb Abr 06, 2024 8:05 pm
Qui Abr 04, 2024 11:34 pm
Qui Abr 04, 2024 11:13 pm
Qui Abr 04, 2024 11:10 pm
Sex Mar 22, 2024 2:41 pm
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
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 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



































































































Colocar som ao carro

Ir para baixo

DÚVIDA Colocar som ao carro

Mensagem por Homem do acre Qua Abr 22, 2020 12:02 pm

Código:
internal enum driveType
{
FrontWheelDrive,
RearWheelDrive,
AllWheelDrive
}

public float topSpeed;
public float accleration;
public float boostForce = 1000;
public float boostAmt = 1000;
[HideInInspector] public bool isBoosting;
public float brakingPower;
public float driftPower;
public bool driftAllowed = false;
[SerializeField] private driveType carDriveType;
public AnimationCurve gearRatios;
public AnimationCurve torqueCurve;
public bool checkSpeeds = true;
public float[] gearSpeeds;
public float idleRPM, maxGearChangeRPM, minGearChangeRPM;
[HideInInspector]public float smoothTime = 0.3f;
public float finalDriveRatio1, finalDriveRatio2;
public float speedMultiplier = 2.23694f;
public float topSpeedDrag = 0.032f, idleDrag = 0.05f, runningDrag = 0.01f;
public float forwardFrictionSpeedFactor;
public float baseFwdExtremum = 1, baseFwdAsymptote = 0.5f;
public float baseSideAsymptote, baseSideExtremum;
public float driftVelocityFactor;
public float defaultForwardStiffness;
public float maxSidewaysStiffness;
public float maxSidewaysFrictionValue;
public float turnPower;
public float revTorquePower;
public float differentialTorqueDrop;
[HideInInspector]public float turnRange = 4f;
[HideInInspector]public float autoStraight = 1;
[HideInInspector]public float cgy;
[HideInInspector]public float turnCheckSense = 10000;
[HideInInspector]public float acc;
[HideInInspector]public float throttle;
public Transform resetPoint;
public Transform[] wheelMesh;
public WheelCollider[] wheelColliders;
public float maxSteerAngle;
public float steerSensitivity;
public float speedDependencyFactor;
public float steerAngleLimitingFactor;
[HideInInspector]public float engineRPM;
[HideInInspector]public int gearNum;
[Range (0, 1)] public float _steerHelper;
[HideInInspector]public float currSpeed;
[HideInInspector]public float fwdInput, backInput, horizontalInput;
[HideInInspector]public float traction;
[HideInInspector]public float slipLimit;
[HideInInspector]public float headingAngle;
public float downForce;
public float criticalDonutSpeed;

public float driftX { get; private set; }

//private CarAiController cac;
private InputManager im;
private Rigidbody car;
private float totalTorque;
private float outputTorque;
private bool recharging = false;
private float wheelRPM;

public float steerAngle{ get; private set; }

private float turnAngle;
private float maxReverseSpeed = 30;
private float reverseDrag = 0.1f;
private float local_finalDrive;
private WheelFrictionCurve fwf, swf;
private float iRPM;
private float thrAgg = 0.8f;
private float currentTorque;
private float oldRotation;
private float localSteerHelper;
private bool drifting;
private bool driftTriggered;
private float upClamp = 0;
private bool prevDriftingStatus = false;
private float boostRefillWait = 5;
private bool isRefilling = false;
private bool burnOut = false;
private float prevAngularVelocity;
private float angularAcclY;
private float prevDriftX = 0;


void Awake ()
{
//cac = GetComponent<CarAiController> ();
car = GetComponent<Rigidbody> ();
im = GetComponent<InputManager> ();
}

void FixedUpdate ()
{
fwdInput = im.forward;
backInput = im.backward;
horizontalInput = im.Horizontal;
adjustFinalDrive ();
addBoostTorque ();
moveCar ();
steerCar ();
brakeCar ();
animateWheels ();
getCarSpeed ();
calcTurnAngle ();
adjustDrag ();
adjustForwardFriction ();
adjustSidewaysFriction ();
rotationalStabilizer ();
steerHelper ();
tractionControl ();
driftCar ();
resetCar ();
CalculateHeadingAngle ();


}

void resetCar ()
{
if (Input.GetKeyDown (KeyCode.R)) {
car.velocity = Vector3.zero;
transform.position = resetPoint.position;
transform.forward = resetPoint.forward;
}
}

void moveCar ()
{
float leftWheelTorque = 0;
float rightWheelTorque = 0;
calcTorque ();
if (carDriveType == driveType.AllWheelDrive) {
outputTorque = totalTorque / 4;
leftWheelTorque = outputTorque * (1 - Mathf.Clamp (differentialTorqueDrop * ((steerAngle < 0) ? -steerAngle : 0), 0, 0.9f));
rightWheelTorque = outputTorque * (1 - Mathf.Clamp (differentialTorqueDrop * ((steerAngle > 0) ? steerAngle : 0), 0, 0.9f));
wheelColliders [0].motorTorque = wheelColliders [2].motorTorque = leftWheelTorque;
wheelColliders [1].motorTorque = wheelColliders [3].motorTorque = rightWheelTorque;
} else if (carDriveType == driveType.FrontWheelDrive) {
outputTorque = totalTorque / 2;
for (int i = 0; i < 2; i++) {
wheelColliders [i].motorTorque = outputTorque;
}
} else {
outputTorque = totalTorque / 2;
for (int i = 2; i < 4; i++) {
wheelColliders [i].motorTorque = outputTorque;
}
}
}

void steerCar ()
{
float x = horizontalInput * (maxSteerAngle - (currSpeed / topSpeed) * steerAngleLimitingFactor);
float steerSpeed = steerSensitivity + (currSpeed / topSpeed) * speedDependencyFactor;

steerAngle = Mathf.SmoothStep (steerAngle, x, steerSpeed);

wheelColliders [0].steerAngle = steerAngle;
wheelColliders [1].steerAngle = steerAngle;

if (!isFlying ())
car.AddRelativeTorque (transform.up * turnPower * currSpeed * horizontalInput);
}

void brakeCar ()
{
int dir = 0;

for (int i = 0; i < 4; i++) {
if (Input.GetKey (KeyCode.Space)) {
wheelColliders [i].brakeTorque = brakingPower;
} else
wheelColliders [i].brakeTorque = 0;
}

if (backInput < 0 && wheelRPM > 0 && currSpeed > 0) {
dir = 1;
} else if (fwdInput > 0 && wheelRPM < 0 && currSpeed < 0) {
dir = 1;
}
wheelColliders [0].brakeTorque = wheelColliders [1].brakeTorque = dir * brakingPower;

if ((Input.GetKey (KeyCode.W) && Input.GetKey (KeyCode.S)) || (Input.GetKey (KeyCode.DownArrow) && Input.GetKey (KeyCode.UpArrow)) && currSpeed < 5) {
burnOut = true;
wheelColliders [0].brakeTorque = wheelColliders [1].brakeTorque = 5000;
} else
burnOut = false;
}

void driftCar ()
{
if (currSpeed > 0 && Mathf.Abs (horizontalInput) > 0 && (backInput < 0 || Input.GetKey (KeyCode.Space)) && (!isFlying ())) {
driftTriggered = true;
float localDriftPower = (Input.GetKey (KeyCode.Space) || im.ReturnPlayerType () == 2) ? driftPower : 0.8f * driftPower;
float torque = Mathf.Clamp (localDriftPower * horizontalInput * currSpeed, -15000, 15000);
car.AddRelativeTorque (transform.up * torque);

} else {
driftTriggered = false;
}
}

void adjustFinalDrive ()
{
if (gearNum == 1 || gearNum == 4 || gearNum == 5) {
local_finalDrive = finalDriveRatio1;
} else {
local_finalDrive = finalDriveRatio2;
}
}

void addBoostTorque ()
{
if (Input.GetKey (KeyCode.LeftShift) && boostAmt > 0 && currSpeed > 0) {
isBoosting = true;
isRefilling = false;
boostAmt = Mathf.MoveTowards (boostAmt, 0, 0.15f);
} else
isBoosting = false;

if (Input.GetKeyUp (KeyCode.LeftShift)) {
StartCoroutine (boostWaitBeforeRefill ());
}

if (isRefilling) {
boostAmt = Mathf.MoveTowards (boostAmt, 100, 0.05f);
}
}

IEnumerator boostWaitBeforeRefill ()
{
yield return new WaitForSeconds (boostRefillWait);
isRefilling = true;
}

void calcTorque ()
{
acc = (gearNum == 1) ? Mathf.MoveTowards (0, 1 * fwdInput, thrAgg) : accleration;
throttle = (gearNum == -1) ? backInput : fwdInput;
shiftGear ();
getEngineRPM ();
totalTorque = torqueCurve.Evaluate (engineRPM) * (gearRatios.Evaluate (gearNum)) * local_finalDrive * throttle * acc;
if (isBoosting) {
totalTorque += boostForce;
}
if (engineRPM >= maxGearChangeRPM)
totalTorque = 0;
tractionControl ();
}

void shiftGear ()
{
if ((gearNum < gearRatios.length - 1 && engineRPM >= maxGearChangeRPM || (gearNum == 0 && (fwdInput > 0 || backInput < 0))) && !isFlying () && checkGearSpeed ()) {
http://Debug.Log (currSpeed);
gearNum++;
}

if (gearNum > 1 && engineRPM <= minGearChangeRPM)
gearNum--;
if (checkStandStill () && backInput < 0)
gearNum = -1;
if (gearNum == -1 && checkStandStill () && fwdInput > 0)
gearNum = 1;
}

bool checkGearSpeed ()
{
if (gearNum != -1) {
if (checkSpeeds) {
return currSpeed >= gearSpeeds [gearNum - 1];
} else
return true;
} else
return false;
}

void idlingRPM ()
{
iRPM = (gearNum > 1) ? 0 : idleRPM;
}

void getEngineRPM ()
{
idlingRPM ();
getWheelRPM ();
float velocity = 0.0f;
engineRPM = Mathf.SmoothDamp (engineRPM, iRPM + (Mathf.Abs (wheelRPM) * local_finalDrive * gearRatios.Evaluate (gearNum)), ref velocity, smoothTime);
}

void getWheelRPM ()
{
float sum = 0;
int c = 0;
for (int i = 0; i < 4; i++) {
if (wheelColliders [i].isGrounded) {
sum += wheelColliders [i].rpm;
c++;
}
}
wheelRPM = (c != 0) ? sum / c : 0;
}

void getInput ()
{
fwdInput = (Input.GetAxis ("Vertical") > 0) ? Input.GetAxis ("Vertical") : 0;
backInput = (Input.GetAxis ("Vertical") < 0) ? Input.GetAxis ("Vertical") : 0;
horizontalInput = Input.GetAxis ("Horizontal");
}

void getCarSpeed ()
{
currSpeed = Vector3.Dot (transform.forward.normalized, car.velocity);
currSpeed *= speedMultiplier;
currSpeed = Mathf.Round (currSpeed);
}

void animateWheels ()
{
Vector3 wheelPosition = Vector3.zero;
Quaternion wheelRotation = Quaternion.identity;

for (int i = 0; i < 4; i++) {
wheelColliders [i].GetWorldPose (out wheelPosition, out wheelRotation);
wheelMesh [i].position = wheelPosition;
wheelMesh [i].rotation = wheelRotation;
}
}

void adjustDrag ()
{
if (currSpeed >= topSpeed)
car.drag = topSpeedDrag;
else if (outputTorque == 0)
car.drag = idleDrag;
else if (currSpeed >= maxReverseSpeed && gearNum == -1 && wheelRPM <= 0)
car.drag = reverseDrag;
else {
car.drag = runningDrag;
}
}

bool isFlying ()
{
if (!wheelColliders [0].isGrounded && !wheelColliders [1].isGrounded && !wheelColliders [2].isGrounded && !wheelColliders [3].isGrounded) {
return true;
} else
return false;
}

bool checkStandStill ()
{
if (currSpeed == 0) {
return true;
} else {
return false;
}
}

void calcTurnAngle ()
{
Vector3 flatForward = transform.forward;
flatForward.y = 0;
if (flatForward.sqrMagnitude > 0) {
flatForward.Normalize ();
Vector3 localFlatForward = transform.InverseTransformDirection (flatForward);
turnAngle = Mathf.Atan2 (localFlatForward.x, localFlatForward.z) * turnCheckSense;
}
}

bool isTurning ()
{
if (turnAngle > -turnRange && turnAngle < turnRange)
return false;
else
return true;
}

void adjustForwardFriction ()
{
fwf = wheelColliders [0].forwardFriction;
fwf.extremumValue = baseFwdExtremum + ((currSpeed <= 0) ? 0 : currSpeed / topSpeed) * forwardFrictionSpeedFactor;
fwf.asymptoteValue = baseFwdAsymptote + ((currSpeed <= 0) ? 0 : currSpeed / topSpeed) * forwardFrictionSpeedFactor;

fwf.extremumValue = Mathf.Clamp (fwf.extremumValue, baseFwdExtremum, 5);
fwf.asymptoteValue = Mathf.Clamp (fwf.asymptoteValue, baseFwdAsymptote, 5);

if (burnOut) {
fwf.extremumValue = 0.1f;
fwf.asymptoteValue = 0.1f;
}

for (int i = 0; i < 4; i++) {
wheelColliders [i].forwardFriction = fwf;
}
}

void adjustSidewaysFriction ()
{
upClamp = Mathf.SmoothStep (upClamp, maxSidewaysFrictionValue, 0.2f);
driftX = Mathf.Abs (transform.InverseTransformVector (car.velocity).x);
float driftFactor = driftX * driftVelocityFactor;

swf = wheelColliders [0].sidewaysFriction;

float x = baseSideAsymptote + driftFactor;
float y = baseSideExtremum + driftFactor;

if (Mathf.Abs (currSpeed) < criticalDonutSpeed) {
swf.stiffness = 0.8f;
} else
swf.stiffness = maxSidewaysStiffness;

swf.asymptoteValue = Mathf.Clamp (x, baseSideAsymptote, maxSidewaysFrictionValue);
swf.extremumValue = Mathf.Clamp (y, baseSideAsymptote, maxSidewaysFrictionValue);

for (int i = 0; i < 4; i++) {
wheelColliders [i].sidewaysFriction = swf;
}
}

void steerHelper ()
{
localSteerHelper = Mathf.SmoothStep (localSteerHelper, _steerHelper * Mathf.Abs (horizontalInput), 0.1f);
if (Input.GetKey (KeyCode.S) || Input.GetKey (KeyCode.DownArrow)) {
_steerHelper *= -1;
}

foreach (WheelCollider wc in wheelColliders) {
WheelHit wheelHit;
wc.GetGroundHit (out wheelHit);
if (wheelHit.normal == Vector3.zero)
return;
}

if (Mathf.Abs (oldRotation - transform.eulerAngles.y) < 10) {
float turnAdjust = (transform.eulerAngles.y - oldRotation) * _steerHelper;
Quaternion velRotation = Quaternion.AngleAxis (turnAdjust, Vector3.up);
car.velocity = velRotation * car.velocity;
}

oldRotation = transform.eulerAngles.y;
}

void addDownForce ()
{
car.AddForce (-transform.up * downForce * car.velocity.magnitude);
}

void adjustTorque (float forwardSlip)
{
if (forwardSlip >= slipLimit && currentTorque >= 0) {
currentTorque -= 1000 * traction;
} else {
currentTorque += 1000 * traction;
if (currentTorque >= totalTorque) {
currentTorque = totalTorque;
}
}
}

void rotationalStabilizer ()
{
calcAngularAccl ();

float reverseTorque = -1 * Mathf.Abs (angularAcclY) * revTorquePower * Mathf.Sign (car.angularVelocity.y) * (currSpeed / topSpeed);

car.AddRelativeTorque (transform.up * reverseTorque);
}

void calcAngularAccl ()
{
angularAcclY = (prevAngularVelocity - car.angularVelocity.y) / Time.deltaTime;
prevAngularVelocity = car.angularVelocity.y;
}

void tractionControl ()
{
WheelHit wheelHit;

switch (carDriveType) {
case driveType.AllWheelDrive:
foreach (WheelCollider wc in wheelColliders) {
wc.GetGroundHit (out wheelHit);
adjustTorque (wheelHit.forwardSlip);
}

break;
case driveType.RearWheelDrive:
wheelColliders [2].GetGroundHit (out wheelHit);
adjustTorque (wheelHit.forwardSlip);
wheelColliders [3].GetGroundHit (out wheelHit);
adjustTorque (wheelHit.forwardSlip);

break;
case driveType.FrontWheelDrive:
wheelColliders [0].GetGroundHit (out wheelHit);
adjustTorque (wheelHit.forwardSlip);
wheelColliders [1].GetGroundHit (out wheelHit);
adjustTorque (wheelHit.forwardSlip);

break;
}
}

void CalculateHeadingAngle ()
{
headingAngle = Mathf.Clamp (Mathf.Round (Vector3.SignedAngle (transform.forward, Vector3.forward, Vector3.up)), -90, 90);
}

Homem do acre
Iniciante
Iniciante

Masculino PONTOS : 1496
REPUTAÇÃO : 0
Idade : 23
Respeito as regras : Colocar som ao carro WvDYdlf

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