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:
OBJETO sendo detruído imediatamente mesmo com o...
Meu site de Modelos 3D
DÚVIDA - ao pressionar andar, o player parece cancelar a gravidade (VÍDEO)
[RESLVIDO] Unity - "transform.SetParent()" em 2 objetos move outros objetos
Dúvida sobre resoluções de tela
Duvida na AppleStore
pressionando a tecla abaixar, o player continua andando abaixado (2D).
Fala Pessoal! Saiu mais um trailer do jogo que venho desenvolvendo
[RESOLVIDO] passar de uma animação para a outra rapidamente pelo animator
Unity - PlayerPrefs n são apagados no Celular mesmo Reiniciando o Aparelho
Modeloes 3D do Site Sketchfab
Blender - Modelos Importados transparentes
[PEDIDO]Cololar jogo na loja play store
Como pegar um objeto e fazer ele aparecer em forma de Estamina no Inspector
Procuro Pessoas para Projeto
Algum tutorial de como fazer um app que receba fotos e q fiqu armazenado no
Procuro um time para um jogo de corrida
[RESOLVIDO] Botões de Ataque e Pular carrega duas animações ao mesmo tempo
DEATH ISLAND 0.2.5 SURVIVAL GAME 4 ANOS EM DESENVOLVIMENTO
Player travando na colisão com o chão Unity 2D
Como resolver vazamento de memoria?
Instanciar uma classe nos atributos de outra classe é uma boa prática?
Jogo multiplayer com steam
Unity - Renderizção com Câmera Jogo Lento e travando. Alguém pfv?!
Mini Quarteirão com Texturas 3D VENDA
Controle do braço e cabeça no fps
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Ativar o objeto correto em Clones.
[TUTORIAL] Como fazer um interruptor simples (Unity 2018)
Preciso de 20 testadores jogo mobile
O Labirinto II - Trailer Oficial
Ue posso divulgar meu game que ainda esta em criaçao aqui no forum?
[RESOLVIDO] Inverter o sprite para a direçao que o personagem anda.
Set Active não a reabiilitado C#
Build APK VR Google Cardbord com video.
[PROGRAMADOR FREELA] $$
Mais Um jogo!
Collider (mesh?)
[TUTORIAL] Deformar mesh com batidas (para objetos, veículos, etc)
WW2 Low poly Pack (Free)
Procuro freelancer
Novo Teaser do jogo Dark Age
Unity Admob Erro
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
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
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
Sex Out 18, 2024 4:05 pm
Dom Out 06, 2024 6:02 pm
Sáb Out 05, 2024 6:37 am
Qui Out 03, 2024 10:09 pm
Seg Set 30, 2024 9:25 am
Sáb Set 28, 2024 11:39 am
Seg Set 09, 2024 7:33 am
Dom Set 08, 2024 10:08 pm
Ter Set 03, 2024 11:59 am
Qua Ago 28, 2024 7:45 pm
Qua Ago 28, 2024 7:18 pm
Qua Ago 28, 2024 8:34 am
Dom Ago 25, 2024 8:37 pm
Sáb Ago 24, 2024 1:58 pm
Sex Ago 23, 2024 3:30 pm
Sex Ago 23, 2024 3:23 pm
Qua Ago 21, 2024 5:48 pm
Dom Ago 18, 2024 8:51 pm
Sex Ago 16, 2024 12:59 pm
Qua Ago 14, 2024 10:57 am
Sáb Ago 10, 2024 8:03 pm
Sex Ago 09, 2024 7:37 pm
Dom Ago 04, 2024 4:41 pm
Dom Ago 04, 2024 3:16 pm
Qui Jul 25, 2024 2:48 pm
Dom Jul 21, 2024 7:07 pm
Dom Jul 21, 2024 12:07 am
Sáb Jul 13, 2024 12:33 am
Qui Jun 27, 2024 5:49 pm
Qui Jun 20, 2024 12:30 pm
Dom Jun 09, 2024 7:43 pm
Dom Jun 09, 2024 2:16 pm
Seg Jun 03, 2024 11:39 am
Seg maio 27, 2024 12:45 pm
Seg maio 20, 2024 9:01 pm
Dom maio 19, 2024 3:08 pm
Sáb maio 18, 2024 11:46 am
Sáb maio 11, 2024 8:55 am
Qui maio 09, 2024 11:33 pm
Seg Abr 29, 2024 9:34 pm
Qui Abr 25, 2024 3:34 pm
Seg Abr 22, 2024 5:15 pm
Seg Abr 15, 2024 12:23 pm
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
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 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



































































































Entrar no carro com ThirdPerson [C#]

4 participantes

Ir para baixo

DÚVIDA Entrar no carro com ThirdPerson [C#]

Mensagem por thiagotmi Ter Dez 19, 2017 6:23 pm

Quero fazer um sistema para entrar no carro em C# com o meu player ThirdPerson(no caso eu tenho um asset chamado Invector TPC).
thiagotmi
thiagotmi
Avançado
Avançado

Masculino PONTOS : 2608
REPUTAÇÃO : 14
Idade : 25
Áreas de atuação : Design, animação, programação básica.
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por recagonlei Ter Dez 19, 2017 6:49 pm

Se tu quer é só começar então... Qual o problema? Dúvidas? Já começou a criar alguma coisa? Estamos aqui para ajudar a criar e tirar dúvidas, não para criarmos ou pesquisarmos a criação para ti! Abraços, sucesso velho!
recagonlei
recagonlei
MembroAvançado

Masculino PONTOS : 3603
REPUTAÇÃO : 185
Idade : 104
Áreas de atuação : ~Programação (C#, HTML, CSS3, Python)
~Modelagem
~Produtor musical
~Ex instrutor Schultz Games
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

http://stwodio.ga

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por thiagotmi Ter Dez 19, 2017 9:14 pm

recagonlei escreveu:Se tu quer é só começar então... Qual o problema? Dúvidas? Já começou a criar alguma coisa? Estamos aqui para ajudar a criar e tirar dúvidas, não para criarmos ou pesquisarmos a criação para ti! Abraços, sucesso velho!
Opa eu esqueci de adicionar a duvida... É que eu tenho um asset de controle (se chama invector TPC) mas não consigo acoplar um script que o faça entrar no carro, ou um script sei lá que desative os scripts do Player e ative os scripts do Carro.
thiagotmi
thiagotmi
Avançado
Avançado

Masculino PONTOS : 2608
REPUTAÇÃO : 14
Idade : 25
Áreas de atuação : Design, animação, programação básica.
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por recagonlei Ter Dez 19, 2017 11:19 pm

Entendi velho... Puts, ai fica complicado cara, pois é um assets de terceiros! Tu deveria pedir suporte para os criadores, que eles entendem melhor do asset e conseguem te ajudar. Mas como tu não consegue desativar os scripts do player? Cacheie todos eles em um outro script e passe uma função para desativa-los... Qual seria o erro?
recagonlei
recagonlei
MembroAvançado

Masculino PONTOS : 3603
REPUTAÇÃO : 185
Idade : 104
Áreas de atuação : ~Programação (C#, HTML, CSS3, Python)
~Modelagem
~Produtor musical
~Ex instrutor Schultz Games
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

http://stwodio.ga

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por Phph09 Qua Dez 20, 2017 6:41 pm

Mande uma foto dos scripts do player e outra dos scripts do carro para podermos te ajudar;
Phph09
Phph09
Profissional
Profissional

Masculino PONTOS : 3758
REPUTAÇÃO : 240
Idade : 19
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por thiagotmi Qui Dez 21, 2017 6:17 pm

Código:
using UnityEngine;
using System.Collections;

namespace Invector.CharacterController
{
    [vClassHeader("Third Person Controller")]
    public class vThirdPersonController : vThirdPersonAnimator
    {
        #region Variables

        public static vThirdPersonController instance;

        #endregion
     
        protected virtual void Awake()
        {
            StartCoroutine(UpdateRaycast()); // limit raycasts calls for better performance           
        }

        protected virtual void Start()
       {
          if (instance == null)
          {
             instance = this;
             DontDestroyOnLoad(this.gameObject);
             this.gameObject.name = gameObject.name + " Instance";
          }
          else
          {
             Destroy(this.gameObject);
             return;
          }             

            #if !UNITY_EDITOR
                Cursor.visible = false;
            #endif
        }               
     
        #region Locomotion Actions
       
        public virtual void Sprint(bool value)
        {
            if(value)
            {
                if (currentStamina > 0 && input.sqrMagnitude > 0.1f)
                {
                    if (isGrounded && !isCrouching)
                        isSprinting = !isSprinting;
                }
            }
            else if (currentStamina <= 0 || input.sqrMagnitude < 0.1f || actions || isStrafing && !strafeWalkByDefault && (direction >= 0.5 || direction <= -0.5 || speed <= 0))
            {               
                isSprinting = false;
            }               
        }

        public virtual void Crouch()
        {                                   
            if (isGrounded && !actions)
            {
                if (isCrouching && CanExitCrouch())
                    isCrouching = false;
                else
                    isCrouching = true;
            }               
        }

        public virtual void Strafe()
        {
            isStrafing = !isStrafing;
        }

        public virtual void Jump()
        {
            if (customAction) return;
                     
            // know if has enough stamina to make this action
           bool staminaConditions = currentStamina > jumpStamina;
            // conditions to do this action
            bool jumpConditions = !isCrouching && isGrounded && !actions && staminaConditions && !isJumping;
            // return if jumpCondigions is false
            if (!jumpConditions) return;          
           // trigger jump behaviour
           jumpCounter = jumpTimer;
           isJumping = true;
            // trigger jump animations
            if (input.sqrMagnitude < 0.1f)
               animator.CrossFadeInFixedTime("Jump", 0.1f);
            else
               animator.CrossFadeInFixedTime("JumpMove", .2f);          
           // reduce stamina
            ReduceStamina(jumpStamina, false);
            currentStaminaRecoveryDelay = 1f;
        }

        public virtual void Roll()
        {
            if (animator.IsInTransition(0)) return;

           bool staminaCondition = currentStamina > rollStamina;
            // can roll even if it's on a quickturn or quickstop animation
            bool actionsRoll = !actions || (actions && (quickStop));
            // general conditions to roll
            bool rollConditions = (input != Vector2.zero || speed > 0.25f) && actionsRoll && isGrounded && staminaCondition && !isJumping;

           if (!rollConditions || isRolling) return;
          
           animator.SetTrigger("ResetState");
            animator.CrossFadeInFixedTime("Roll", 0.1f);
            ReduceStamina(rollStamina, false);
            currentStaminaRecoveryDelay = 2f;
        }     

        /// <summary>
        /// Use another transform as  reference to rotate
        /// </summary>
        /// <param name="referenceTransform"></param>
        public virtual void RotateWithAnotherTransform(Transform referenceTransform)
        {
            var newRotation = new Vector3(transform.eulerAngles.x, referenceTransform.eulerAngles.y, transform.eulerAngles.z);
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(newRotation), strafeRotationSpeed * Time.fixedDeltaTime);
            targetRotation = transform.rotation;
        }

        #endregion

        #region Check Action Triggers
       
        /// <summary>
        /// Call this in OnTriggerEnter or OnTriggerStay to check if enter in triggerActions   
        /// </summary>
        /// <param name="other">collider trigger</param>                       
        public virtual void CheckTriggers(Collider other)
        {
            try
            {
                CheckForAutoCrouch(other);
            }
            catch (UnityException e)
            {
                Debug.LogWarning(e.Message);
            }
        }

        /// <summary>
        /// Call this in OnTriggerExit to check if exit of triggerActions
        /// </summary>
        /// <param name="other"></param>
        public virtual void CheckTriggerExit(Collider other)
        {           
            AutoCrouchExit(other);
        }

        #region Update Raycasts 

        protected IEnumerator UpdateRaycast()
        {
            while (true)
            {
                yield return new WaitForEndOfFrame();

                AutoCrouch();
                StopMove();
            }
        }   
     
        #endregion

        #region Crouch Methods

        protected virtual void AutoCrouch()
        {
            if (autoCrouch)
                isCrouching = true;

            if (autoCrouch && !inCrouchArea && CanExitCrouch())
            {
                autoCrouch = false;
                isCrouching = false;
            }
        }

        protected virtual bool CanExitCrouch()
        {
            // radius of SphereCast
            float radius = _capsuleCollider.radius * 0.9f;
            // Position of SphereCast origin stating in base of capsule
            Vector3 pos = transform.position + Vector3.up * ((colliderHeight * 0.5f) - colliderRadius);
            // ray for SphereCast
            Ray ray2 = new Ray(pos, Vector3.up);

            // sphere cast around the base of capsule for check ground distance
            if (Physics.SphereCast(ray2, radius, out groundHit, headDetect - (colliderRadius * 0.1f), autoCrouchLayer))
                return false;
            else
                return true;
        }

        protected virtual void AutoCrouchExit(Collider other)
        {
            if (other.CompareTag("AutoCrouch"))
            {
                inCrouchArea = false;
            }
        }

        protected virtual void CheckForAutoCrouch(Collider other)
        {
            if (other.gameObject.CompareTag("AutoCrouch"))
            {
                autoCrouch = true;
                inCrouchArea = true;
            }
        }

        #endregion

        #endregion
    }
}


Esse aqui é o controller do Player
thiagotmi
thiagotmi
Avançado
Avançado

Masculino PONTOS : 2608
REPUTAÇÃO : 14
Idade : 25
Áreas de atuação : Design, animação, programação básica.
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por thiagotmi Qui Dez 21, 2017 6:19 pm

Código:
//----------------------------------------------
//            Realistic Car Controller
//
// Copyright ©️ 2015 BoneCracker Games
// http://www.bonecrackergames.com
//
//----------------------------------------------

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

[AddComponentMenu("BoneCracker Games/Realistic Car Controller/AI/AI Controller")]
public class RCC_AICarController : MonoBehaviour {

   private RCC_CarControllerV3 carController;
   private Rigidbody rigid;
   
   // Waypoint Container.
   private RCC_AIWaypointsContainer waypointsContainer;
   public int currentWaypoint = 0;
   
   // Raycast distances.
   public LayerMask obstacleLayers = -1;
   public int wideRayLength = 20;
   public int tightRayLength = 20;
   public int sideRayLength = 3;
   private float rayInput = 0f;
   private bool  raycasting = false;
   private float resetTime = 0f;
   
   // Steer, motor, and brake inputs.
   private float steerInput = 0f;
   private float gasInput = 0f;
   private float brakeInput = 0f;

   public bool limitSpeed = false;
   public float maximumSpeed = 100f;

   public bool smoothedSteer = true;
   
   // Brake Zone.
   private float maximumSpeedInBrakeZone = 0f;
   private bool inBrakeZone = false;
   
   // Counts laps and how many waypoints passed.
   public int lap = 0;
   public int totalWaypointPassed = 0;
   public int nextWaypointPassRadius = 40;
   public bool ignoreWaypointNow = false;
   
   // Unity's Navigator.
   private UnityEngine.AI.NavMeshAgent navigator;
   private GameObject navigatorObject;

   void Awake() {

      carController = GetComponent<RCC_CarControllerV3>();
      rigid = GetComponent<Rigidbody>();
      carController.AIController = true;
//      carController.canEngineStall = false;
//      carController.autoReverse = true;
      waypointsContainer = FindObjectOfType(typeof(RCC_AIWaypointsContainer)) as RCC_AIWaypointsContainer;

      navigatorObject = new GameObject("Navigator");
      navigatorObject.transform.parent = transform;
      navigatorObject.transform.localPosition = Vector3.zero;
      navigatorObject.AddComponent<UnityEngine.AI.NavMeshAgent>();
      navigatorObject.GetComponent<UnityEngine.AI.NavMeshAgent>().radius = 1;
      navigatorObject.GetComponent<UnityEngine.AI.NavMeshAgent>().speed = 1f;
      navigatorObject.GetComponent<UnityEngine.AI.NavMeshAgent>().height = 1;
      navigatorObject.GetComponent<UnityEngine.AI.NavMeshAgent>().avoidancePriority = 99;
      navigator = navigatorObject.GetComponent<UnityEngine.AI.NavMeshAgent>();

   }
   
   void Update(){
      
      navigator.transform.localPosition = new Vector3(0, carController.FrontLeftWheelCollider.transform.localPosition.y, carController.FrontLeftWheelCollider.transform.localPosition.z);
      
   }
   
   void  FixedUpdate (){

      if(!carController.canControl)
         return;

      Navigation();
      FixedRaycasts();
      ApplyTorques();
      Resetting();

   }
   
   void Navigation (){
      
      if(!waypointsContainer){
         Debug.LogError("Waypoints Container Couldn't Found!");
         enabled = false;
         return;
      }
      if(waypointsContainer && waypointsContainer.waypoints.Count < 1){
         Debug.LogError("Waypoints Container Doesn't Have Any Waypoints!");
         enabled = false;
         return;
      }
      
      // Next waypoint's position.
      Vector3 nextWaypointPosition = transform.InverseTransformPoint( new Vector3(waypointsContainer.waypoints[currentWaypoint].position.x, transform.position.y, waypointsContainer.waypoints[currentWaypoint].position.z));
      float navigatorInput = Mathf.Clamp(transform.InverseTransformDirection(navigator.desiredVelocity).x * 1.5f, -1f, 1f);

      navigator.SetDestination(waypointsContainer.waypoints[currentWaypoint].position);

      //Steering Input.
      if(carController.direction == 1){
         if(!ignoreWaypointNow)
            steerInput = Mathf.Clamp((navigatorInput + rayInput), -1f, 1f);
         else
            steerInput = Mathf.Clamp(rayInput, -1f, 1f);
      }else{
         steerInput = Mathf.Clamp((-navigatorInput - rayInput), -1f, 1f);
      }
      
      if(!inBrakeZone){
         if(carController.speed >= 25){
            brakeInput = Mathf.Lerp(0f, .25f, (Mathf.Abs(steerInput)));
         }else{
            brakeInput = 0f;
         }
      }else{
         brakeInput = Mathf.Lerp(0f, 1f, (carController.speed - maximumSpeedInBrakeZone) / maximumSpeedInBrakeZone);
      }

      if(!inBrakeZone){
         
         if(carController.speed >= 10){
            if(!carController.changingGear)
               gasInput = Mathf.Clamp(1f - (Mathf.Abs(navigatorInput / 5f)  - Mathf.Abs(rayInput / 5f)), .5f, 1f);
            else
               gasInput = 0f;
         }else{
            if(!carController.changingGear)
               gasInput = 1f;
            else
               gasInput = 0f;
         }

      }else{
         
         if(!carController.changingGear)
            gasInput = Mathf.Lerp(1f, 0f, (carController.speed) / maximumSpeedInBrakeZone);
         else
            gasInput = 0f;

      }
      
      // Checks for the distance to next waypoint. If it is less than written value, then pass to next waypoint.
      if (nextWaypointPosition.magnitude < nextWaypointPassRadius){
         currentWaypoint ++;
         totalWaypointPassed ++;
         
         // If all waypoints are passed, sets the current waypoint to first waypoint and increase lap.
         if (currentWaypoint >= waypointsContainer.waypoints.Count){
            currentWaypoint = 0;
            lap ++;
         }
      }
      
   }
   
   void Resetting (){
      
      if(carController.speed <= 5 && transform.InverseTransformDirection(rigid.velocity).z < 1f)
         resetTime += Time.deltaTime;
      
      if(resetTime >= 4)
         carController.direction = -1;

      if(resetTime >= 6 || carController.speed >= 25){
         carController.direction = 1;
         resetTime = 0;
      }
      
   }
   
   void FixedRaycasts(){
      
      Vector3 forward = transform.TransformDirection ( new Vector3(0, 0, 1));
      Vector3 pivotPos = new Vector3(transform.localPosition.x, carController.FrontLeftWheelCollider.transform.position.y, transform.localPosition.z);
      RaycastHit hit;
      
      // New bools effected by fixed raycasts.
      bool  tightTurn = false;
      bool  wideTurn = false;
      bool  sideTurn = false;
      bool  tightTurn1 = false;
      bool  wideTurn1 = false;
      bool  sideTurn1 = false;
      
      // New input steers effected by fixed raycasts.
      float newinputSteer1 = 0f;
      float newinputSteer2 = 0f;
      float newinputSteer3 = 0f;
      float newinputSteer4 = 0f;
      float newinputSteer5 = 0f;
      float newinputSteer6 = 0f;
      
      // Drawing Rays.
      Debug.DrawRay (pivotPos, Quaternion.AngleAxis(25, transform.up) * forward * wideRayLength, Color.white);
      Debug.DrawRay (pivotPos, Quaternion.AngleAxis(-25, transform.up) * forward * wideRayLength, Color.white);
      
      Debug.DrawRay (pivotPos, Quaternion.AngleAxis(7, transform.up) * forward * tightRayLength, Color.white);
      Debug.DrawRay (pivotPos, Quaternion.AngleAxis(-7, transform.up) * forward * tightRayLength, Color.white);

      Debug.DrawRay (pivotPos, Quaternion.AngleAxis(90, transform.up) * forward * sideRayLength, Color.white);
      Debug.DrawRay (pivotPos, Quaternion.AngleAxis(-90, transform.up) * forward * sideRayLength, Color.white);
      
      // Wide Raycasts.
      if (Physics.Raycast (pivotPos, Quaternion.AngleAxis(25, transform.up) * forward, out hit, wideRayLength, obstacleLayers) && !hit.collider.isTrigger && hit.transform.root != transform) {
         Debug.DrawRay (pivotPos, Quaternion.AngleAxis(25, transform.up) * forward * wideRayLength, Color.red);
         newinputSteer1 = Mathf.Lerp (-.5f, 0f, (hit.distance / wideRayLength));
         wideTurn = true;
      }
      
      else{
         newinputSteer1 = 0f;
         wideTurn = false;
      }
      
      if (Physics.Raycast (pivotPos, Quaternion.AngleAxis(-25, transform.up) * forward, out hit, wideRayLength, obstacleLayers) && !hit.collider.isTrigger && hit.transform.root != transform) {
         Debug.DrawRay (pivotPos, Quaternion.AngleAxis(-25, transform.up) * forward * wideRayLength, Color.red);
         newinputSteer4 = Mathf.Lerp (.5f, 0f, (hit.distance / wideRayLength));
         wideTurn1 = true;
      }else{
         newinputSteer4 = 0f;
         wideTurn1 = false;
      }
      
      // Tight Raycasts.
      if (Physics.Raycast (pivotPos, Quaternion.AngleAxis(7, transform.up) * forward, out hit, tightRayLength, obstacleLayers) && !hit.collider.isTrigger && hit.transform.root != transform) {
         Debug.DrawRay (pivotPos, Quaternion.AngleAxis(7, transform.up) * forward * tightRayLength , Color.red);
         newinputSteer3 = Mathf.Lerp (-1f, 0f, (hit.distance / tightRayLength));
         tightTurn = true;
      }else{
         newinputSteer3 = 0f;
         tightTurn = false;
      }
      
      if (Physics.Raycast (pivotPos, Quaternion.AngleAxis(-7, transform.up) * forward, out hit, tightRayLength, obstacleLayers) && !hit.collider.isTrigger && hit.transform.root != transform) {
         Debug.DrawRay (pivotPos, Quaternion.AngleAxis(-7, transform.up) * forward * tightRayLength, Color.red);
         newinputSteer2 = Mathf.Lerp (1f, 0f, (hit.distance / tightRayLength));
         tightTurn1 = true;
      }else{
         newinputSteer2 = 0f;
         tightTurn1 = false;
      }

      // Side Raycasts.
      if (Physics.Raycast (pivotPos, Quaternion.AngleAxis(90, transform.up) * forward, out hit, sideRayLength, obstacleLayers) && !hit.collider.isTrigger && hit.transform.root != transform) {
         Debug.DrawRay (pivotPos, Quaternion.AngleAxis(90, transform.up) * forward * sideRayLength , Color.red);
         newinputSteer5 = Mathf.Lerp (-1f, 0f, (hit.distance / sideRayLength));
         sideTurn = true;
      }else{
         newinputSteer5 = 0f;
         sideTurn = false;
      }
      
      if (Physics.Raycast (pivotPos, Quaternion.AngleAxis(-90, transform.up) * forward, out hit, sideRayLength, obstacleLayers) && !hit.collider.isTrigger && hit.transform.root != transform) {
         Debug.DrawRay (pivotPos, Quaternion.AngleAxis(-90, transform.up) * forward * sideRayLength, Color.red);
         newinputSteer6 = Mathf.Lerp (1f, 0f, (hit.distance / sideRayLength));
         sideTurn1 = true;
      }else{
         newinputSteer6 = 0f;
         sideTurn1 = false;
      }
      
      if(wideTurn || wideTurn1 || tightTurn || tightTurn1 || sideTurn || sideTurn1)
         raycasting = true;
      else
         raycasting = false;
      
      if(raycasting)
         rayInput = (newinputSteer1 + newinputSteer2 + newinputSteer3 + newinputSteer4 + newinputSteer5 + newinputSteer6);
      else
         rayInput = 0f;
      
      if(raycasting && Mathf.Abs(rayInput) > .5f)
         ignoreWaypointNow = true;
      else
         ignoreWaypointNow = false;
      
   }

   void ApplyTorques(){

      if(carController.direction == 1){
         if(!limitSpeed){
            carController.gasInput = gasInput;
         }else{
            carController.gasInput = gasInput * Mathf.Clamp01(Mathf.Lerp(10f, 0f, (carController.speed) / maximumSpeed));
         }
      }else{
         carController.gasInput = 0f;
      }

      if(smoothedSteer)
         carController.steerInput = Mathf.Lerp(carController.steerInput, steerInput, Time.deltaTime * 20f);
      else
         carController.steerInput = steerInput;

      if(carController.direction == 1)
         carController.brakeInput = brakeInput;
      else
         carController.brakeInput = gasInput;

   }
   
   void OnTriggerEnter (Collider col){
      
      if(col.gameObject.GetComponent<RCC_AIBrakeZone>()){
         inBrakeZone = true;
         maximumSpeedInBrakeZone = col.gameObject.GetComponent<RCC_AIBrakeZone>().targetSpeed;
      }
      
   }
   
   void OnTriggerExit (Collider col){
      
      if(col.gameObject.GetComponent<RCC_AIBrakeZone>()){
         inBrakeZone = false;
         maximumSpeedInBrakeZone = 0;
      }
      
   }
   
}

E esse é do Carro
thiagotmi
thiagotmi
Avançado
Avançado

Masculino PONTOS : 2608
REPUTAÇÃO : 14
Idade : 25
Áreas de atuação : Design, animação, programação básica.
Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por Madness Qui Dez 21, 2017 11:14 pm

Esses sistemas possuem suporte através dos desenvolvedores, e tenho certeza que se pedir eles vão ajudar você :D aqui é o lugar errado para pedir isso!
Madness
Madness
Designer

Masculino PONTOS : 3579
REPUTAÇÃO : 222
Áreas de atuação : Designer
Iniciante C++
Quase um programador C#



Respeito as regras : Entrar no carro com ThirdPerson [C#] WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Entrar no carro com ThirdPerson [C#]

Mensagem por thiagotmi Sex Dez 22, 2017 3:48 am

Madness escreveu:Esses sistemas possuem suporte através dos desenvolvedores, e tenho certeza que se pedir eles vão ajudar você :D aqui é o lugar errado para pedir isso!


Ok! Obrigado!
thiagotmi
thiagotmi
Avançado
Avançado

Masculino PONTOS : 2608
REPUTAÇÃO : 14
Idade : 25
Áreas de atuação : Design, animação, programação básica.
Respeito as regras : Entrar no carro com ThirdPerson [C#] 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