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:
Collider (mesh?)
ShapeKeys do Blender para a Unity altera áreas próximas
Player travando na colisão com o chão Unity 2D
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.
Ontem à(s) 10:47 pm
Sex Mar 22, 2024 2:41 pm
Sex Mar 22, 2024 11:38 am
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



































































































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 : 2400
REPUTAÇÃO : 14
Idade : 24
Á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 : 3395
REPUTAÇÃO : 185
Idade : 103
Á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 : 2400
REPUTAÇÃO : 14
Idade : 24
Á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 : 3395
REPUTAÇÃO : 185
Idade : 103
Á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 : 3550
REPUTAÇÃO : 240
Idade : 18
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 : 2400
REPUTAÇÃO : 14
Idade : 24
Á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 : 2400
REPUTAÇÃO : 14
Idade : 24
Á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 : 3371
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 : 2400
REPUTAÇÃO : 14
Idade : 24
Á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