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:
Como abrir portas/gavetas com click do mouse, usando raycast!
Como resolver problema com lag por conta de sprites Instanciados? Mesmo destruindo em 2f
[TUTORIAL] MENU PRINCIPAL - UNITY 5 (5.3 ou superior) (Com UI)
Unity3D - Meu boneco fica girando no eixo Y sem parar, parece o sonic
Alguém sabe o nome desse efeito?
Ajuda - Como crio um botão touch usando o Bolt visual Scripting
as luzes diminuem mt o fps no android, alguma dica de como melhorar isso?
Usar o mouse?
click mouse
RigidBody Agarrando no BoxCollider [Mobile 3D]
Como alterar informações de objeto UI
Desconectar jogador após acabar o tempo de jogo utilizando a rede - Bolt
quero adicionar mais colisores a esse script de movimentação
The freddy krueger's pie (Game)
SEM CURSOR EM JOGO.
Conexão entre app Android e internet.
CURSOR DO MOUSE NÃO DESAPARECE AO CLICAR EM "JOGAR" NO MENU
Script não funcionando
Destruir um objeto ao colidir com o componente dele.
RigidBodyFPSController não carrega o script, é do pacote standard assets
Preciso saber matemática para programar?
[RESOLVIDO] Prefab com altura diferente na Scene
Problema com os FPS do jogo
pq da erro ao tentar mover arquivo para unity
[RESOLVIDO] Como saber se um Transform está se movendo?
Problema com animaç]ao de fechar porta ao clicar com mouse raycast
Fala Pessoal! saiu um trailer da sequência do meu jogo Project Lazarus parte 2
Exportação do SketchUp para Unity
[RESOLVIDO] Como fazer com que os valores do bool sejam iguais ao da lista?
[RESOLVIDO] Trocar valor de variável apos X segundos que ativar o triggercollider
PEGADAS DO PLAYER QUE APARECEM APÓS ANDAR SOBRE UMA ÁREA "ÚMIDA". UNITY 2D
[RESOLVIDO] Erro com Facebook SDK
Como deixar touch apenas 50% da tela (código que estou usando)
terreno plano pesa muito em mobile?
Dúvida sobre o script de Mover Objetos
Duvida sobre um sistema de Lap Timer junto com o box collider!
Como passar cena sem perder o que conseguiu em outra?
[RESOLVIDO] OverlapBox detectar colisão
APK trava com Admob
[Lançado] TapNav: Vaporwave Edition já está disponível!
[RESOLVIDO] Tentando implementar sons no Character Controller
como posso criar um filtro de cor igual post processing?
[RESOLVIDO] Problema com movimentação do Joystick
Inimigo aparecer depois de certa ação
Como redirecionar o usuário pelo app do Facebook?
[TUTORIAL] Codificar e Decodificar Numeros
Como fazer esse mesmo código usando ScriptableObject?
[RESOLVIDO] Pontuação na Unity 3D!
[RESOLVIDO] Unity 2018.2.17 Problemas com o Package Manager
BARRA DE ENERGIA NÃO RESETA QUANDO O PLAYER RENASCE.
[RESOLVIDO] Erro no pacote do Unity Ads
Fazer o personagem apontar na direção do movimento
[TUTORIAL] Sistema de fome, sede, barra de vida, barra de estamina, itens e dano por queda
QUE ? Porque não funcionou ? :(
Personagem da AS, animações do mixamo dão erro ao usar avatar do personagem.
[RESOLVIDO] Meus personagens não iniciam animação no jogo compilado, o que pode ser ?
Como deixar touch apenas 50% da tela
Sistema de tiro teleguiado
[TUTORIAL] Script para jogo FPS Mobile
[RESOLVIDO] Como faço para o personagem entrar e sair do carro?
[RESOLVIDO] Como salvar itens da fase?
Oque é API?
Salvar dados unity
NavMesh em uma esfera
[TUTORIAL] Dicas Para Otimização de Código
[POR QUE O OBJETO FICA DEFORMADO QUANDO ROTACIONA?]
Jogo Maria Bella
[DUVIDA]sobre Time.deltaTime
SIGLETON
Shader Causa Tela Preta
Objeto continuar em movimento após tira o dedo da direção
"Problema" com o script de mover objetos versão free do Marcos Schultz
como fazer joystick's Mobile para shooter topDown ?
Unity 2018.2 Erro de janela no Editor
Duvida sobre um script de contagem 1, 2, 3, GO!.
Onde Encontro Música De Background Para o Meu Projeto?
problema na AI quando passa pro unity 2020
[RESOLVIDO] Problema em configurar o pneu de 1 carro no MSVehicle System Free
[RESOLVIDO] Dicas sobre criação de ruas??
[RESOLVIDO] Utilizar o Range
Sistema de Yu-Gi-Oh! - ATT [2020]
Meu jogo Mobile já disponivel na PlayStore ou GameJolt!!
Jogo Santuário Hebreu
[RESOLVIDO] Ancora em UIs
[RESOLVIDO] Uma dúvida sobre Quaternion.Inverse
freelancer para modelador
[TUTORIAL] Sistema de DIA E NOITE completo, com luzes noturnas e SISTEMA DE NUVENS
[RESOLVIDO] Rotacionar Prefab dentro da Scene
Salvamento de jogo utilizando o Google services
Como faço para animar meu personagem?
Desligando a colisão entre layers
Carro Pegar armas em
Rodas do carro nao ficao presas ao carro
Ajuda para jogo da memória! Aleatorizar Cartas
Ajuda compilar para android
como fazer um player se movimentar utilizando força centrípeta
Unity ou Unreal Engine ? Alguém que ja usou UE para opinar?
girar o personagem de acordo com o analógico
[TUTORIAL] Sistema de login com json
Hoje à(s) 12:59 am
Hoje à(s) 12:58 am
Ontem à(s) 8:53 pm
Ontem à(s) 8:10 pm
Ontem à(s) 6:30 pm
Ontem à(s) 6:04 pm
Ontem à(s) 4:51 pm
Ontem à(s) 1:10 pm
Ontem à(s) 10:24 am
Ontem à(s) 10:21 am
Ontem à(s) 10:03 am
Ontem à(s) 2:30 am
Sex Set 18, 2020 10:13 pm
Sex Set 18, 2020 9:40 pm
Sex Set 18, 2020 8:14 am
Sex Set 18, 2020 8:09 am
Qui Set 17, 2020 2:36 pm
Qui Set 17, 2020 10:07 am
Qua Set 16, 2020 11:22 pm
Qua Set 16, 2020 5:31 pm
Qua Set 16, 2020 12:10 pm
Qua Set 16, 2020 12:02 am
Ter Set 15, 2020 11:33 pm
Ter Set 15, 2020 11:32 pm
Ter Set 15, 2020 5:28 pm
Ter Set 15, 2020 11:52 am
Ter Set 15, 2020 6:13 am
Seg Set 14, 2020 3:51 pm
Seg Set 14, 2020 3:41 pm
Seg Set 14, 2020 11:06 am
Seg Set 14, 2020 10:12 am
Seg Set 14, 2020 9:14 am
Seg Set 14, 2020 3:21 am
Seg Set 14, 2020 3:11 am
Dom Set 13, 2020 1:07 am
Sab Set 12, 2020 8:01 pm
Sab Set 12, 2020 6:34 pm
Sab Set 12, 2020 6:32 pm
Sab Set 12, 2020 2:28 pm
Sab Set 12, 2020 2:15 pm
Sab Set 12, 2020 1:20 pm
Sab Set 12, 2020 12:28 pm
Sab Set 12, 2020 1:37 am
Sex Set 11, 2020 7:08 pm
Sex Set 11, 2020 4:30 pm
Sex Set 11, 2020 4:26 pm
Sex Set 11, 2020 1:59 pm
Sex Set 11, 2020 1:40 pm
Qui Set 10, 2020 8:39 pm
Qui Set 10, 2020 6:26 pm
Qui Set 10, 2020 1:01 pm
Qui Set 10, 2020 2:19 am
Qui Set 10, 2020 2:17 am
Qui Set 10, 2020 2:08 am
Qui Set 10, 2020 1:51 am
Qua Set 09, 2020 10:03 pm
Qua Set 09, 2020 5:43 pm
Qua Set 09, 2020 6:21 am
Ter Set 08, 2020 10:47 pm
Ter Set 08, 2020 8:47 pm
Ter Set 08, 2020 12:59 pm
Ter Set 08, 2020 9:55 am
Seg Set 07, 2020 10:41 pm
Seg Set 07, 2020 9:32 pm
Seg Set 07, 2020 9:11 pm
Seg Set 07, 2020 8:07 pm
Seg Set 07, 2020 7:18 pm
Seg Set 07, 2020 3:06 am
Seg Set 07, 2020 2:52 am
Dom Set 06, 2020 9:29 pm
Dom Set 06, 2020 8:37 pm
Dom Set 06, 2020 7:37 pm
Dom Set 06, 2020 6:13 pm
Dom Set 06, 2020 6:12 pm
Dom Set 06, 2020 6:11 pm
Dom Set 06, 2020 5:33 pm
Dom Set 06, 2020 5:30 pm
Dom Set 06, 2020 4:46 pm
Dom Set 06, 2020 11:42 am
Sab Set 05, 2020 9:45 pm
Sab Set 05, 2020 8:29 am
Sex Set 04, 2020 7:53 pm
Sex Set 04, 2020 1:57 pm
Sex Set 04, 2020 11:06 am
Qui Set 03, 2020 9:11 pm
Qui Set 03, 2020 6:55 pm
Qua Set 02, 2020 10:57 pm
Qua Set 02, 2020 5:33 pm
Qua Set 02, 2020 3:49 pm
Qua Set 02, 2020 10:01 am
Qua Set 02, 2020 9:56 am
Ter Set 01, 2020 9:05 pm
Ter Set 01, 2020 4:54 pm
Ter Set 01, 2020 2:44 pm
Ter Set 01, 2020 2:24 pm
Seg Ago 31, 2020 10:43 pm
Seg Ago 31, 2020 8:15 pm
Seg Ago 31, 2020 6:58 pm
Seg Ago 31, 2020 2:44 pm
MarcosSchultz
MarcosSchultz
BatataBugada54321
darkrj
diegopds
Lohmz
JulioWinchester
AndryelBlanco
Magnatah
Magnatah
Magnatah
ProBrStalker
BatataBugada54321
Callyde Jr
NKKF
NKKF
FelipeSouza11
Magnatah
bruno700mb
darkrj
Magnatah
Ricardito
Magnatah
Magnatah
fantastic137
SamonBR
Callyde Jr
Fagner
Th2y
Shidote
ViniciusTKH
TioUV
MarcosSchultz
MarcosSchultz
MarcosSchultz
mateusschw
MayLeone
KurotamaXIII
Ploleo
RodriGO3477
PacienteZERO
Fagner
BlesseD
zhentox
MarcosSchultz
MarcosSchultz
Fagner
SauloeArthur
ProBrStalker
Callyde Jr
tautologias357
MarcosSchultz
MarcosSchultz
MarcosSchultz
MarcosSchultz
Callyde Jr
bruno700mb
Callyde Jr
JulioWinchester
FlavinGiroflex
merike11
TioUV
Weslley
GattiMene
Magnatah
MarcosSchultz
TIKO
MarcosSchultz
MarcosSchultz
Fagner
Magnatah
Rangel Oblivion
MarcosSchultz
ProBrStalker
mateusschw
MarcosSchultz
MarcosSchultz
mateusschw
FlavinGiroflex
Th2y
darknecron
MarceloYBP
TIKO
poyser
pdsimulador
designshake
SamonBR
Ricardito
Fagner
Moskeiro
Moskeiro
CharlesWarrior02
samuelreidosjogos17091997
AndryelBlanco
NKKF
samuelreidosjogos17091997
Fagner
Wrench18
Lplucas

Camera Height

Ir em baixo

DÚVIDA Camera Height

Mensagem por saccasolutions em Seg Maio 11, 2020 7:54 pm

I have attached the camera controller to a UMA Avatar but it focuses at the avatars feet. How can I adjust the height of the camera? Can this be done in the script?


Since the avatar is created at runtime I do not know how else I could attach the camera controller to anything else as part of the avatar.


Here you help?

saccasolutions
Iniciante
Iniciante

PONTOS : 139
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por Fagner em Seg Maio 11, 2020 9:22 pm

There's a "script" button in the page that you write your message, use it to paste your code.
In general, any camera controller look at the origin point of the transform, if is not a option to use a custom transform as position, you can add a offset in the code, like this:
Vector3 offset = new Vector3(0, 1 ,0)
This represents a height of 1 meter in Y axis. 
Now you can sum this vector to the position of the transform.
Look for a line like this;
Transform.LookAt(player/target)

Change to this:
Transform.LookAt(player/target + offset)
I hope this helps.
Fagner
Fagner
Moderador

Masculino PONTOS : 2279
REPUTAÇÃO : 409
Áreas de atuação : Modelagem 3D, Programação.
Respeito as regras : Camera Height  Aad8pUi

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions em Seg Maio 11, 2020 10:53 pm

@Fagner escreveu: There's a "script" button in the page that you write your message, use it to paste your code.
In general, any camera controller look at the origin point of the transform, if is not an option to use a custom transform as position, you can add a offset in the code, like this:
Vector3 offset = new Vector3 (0, 1, 0)
This represents a height of 1 meter in Y axis. 
Now you can sum this vector to the position of the transform.
Look for a line like this;
Transform.LookAt (player / target)

Change to this:
Transform.LookAt (player / target + offset)
I hope this helps.
I'm using the standard script and seeking to add this offset to the "Follow player" option. Here is the script. 

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

[Serializable]
public class MSACC_CameraType {
   [Tooltip("A camera must be associated with this variable. The camera that is associated here, will receive the settings of this index.")]
   public Camera _camera;
   public enum TipoRotac{LookAtThePlayer, FirstPerson, FollowPlayer, Orbital, Stop, StraightStop, OrbitalThatFollows, ETS_StyleCamera, FlyCamera_OnlyWindows}
   [Tooltip("Here you must select the type of rotation and movement that camera will possess.")]
   public TipoRotac rotationType = TipoRotac.LookAtThePlayer;
   [Range(0.01f,1.0f)][Tooltip("Here you must adjust the volume that the camera attached to this element can perceive. In this way, each camera can perceive a different volume.")]
   public float volume = 1.0f;
}
[Serializable]
public class MSACC_CameraSetting {
   [Header("Configure Inputs")]
   [Tooltip("The input that will define the horizontal movement of the cameras.")]
   public string inputMouseX = "Mouse X";
   [Tooltip("The input that will define the vertical movement of the cameras.")]
   public string inputMouseY = "Mouse Y";
   [Tooltip("The input that allows you to zoom in or out of the camera.")]
   public string inputMouseScrollWheel = "Mouse ScrollWheel";
   [Tooltip("In this variable you can configure the key responsible for switching cameras.")]
   public KeyCode cameraSwitchKey = KeyCode.C;

   public enum UpdateMode {Update, FixedUpdate, LateUpdate};
   [Header("Update mode")]
   [Tooltip("Here it is possible to decide whether the motion of the cameras will be processed in the void Update, FixedUpdate or LateUpdate. The mode that best suits most situations is the 'LateUpdate'.")]
   public UpdateMode camerasUpdateMode = UpdateMode.LateUpdate;

   [Header("General settings")]
   [Tooltip("If this variable is checked, the script will automatically place the 'IgnoreRaycast' layer on the player when needed.")]
   public bool ajustTheLayers = true;
   [Tooltip("In this class you can configure the 'FirstPerson' style cameras.")]
   public MSACC_SettingsCameraFirstPerson firstPerson;
   [Tooltip("In this class you can configure the 'FollowPlayer' style cameras.")]
   public MSACC_SettingsCameraFollow followPlayer;
   [Tooltip("In this class you can configure the 'Orbital' style cameras.")]
   public MSACC_SettingsCameraOrbital orbital;
   [Tooltip("In this class you can configure the 'OrbitalThatFollows' style cameras.")]
   public MSACC_SettingsCameraOrbitalThatFollows OrbitalThatFollows;
   [Tooltip("In this class you can configure the 'ETS_StyleCamera' style cameras.")]
   public MSACC_SettingsCameraETS_StyleCamera ETS_StyleCamera;
   [Tooltip("In this class you can configure the 'FlyCamera' style cameras.")]
   public MSACC_SettingsFlyCamera FlyCamera_OnlyWindows;
}
[Serializable]
public class MSACC_SettingsCameraFirstPerson {
   [Header("Sensibility")]
   [Range(1,20)][Tooltip("Horizontal camera rotation sensitivity.")]
   public float sensibilityX = 10.0f;
   [Range(1,20)][Tooltip("Vertical camera rotation sensitivity.")]
   public float sensibilityY = 10.0f;
   [Range(0,1)][Tooltip("The speed with which the camera can approach your vision through the mouseScrool.")]
   public float speedScroolZoom = 0.5f;
   [Header("Limits")]
   [Range(0,360)][Tooltip("The highest horizontal angle that camera style 'FistPerson' camera can achieve.")]
   public float horizontalAngle = 65.0f;
   [Range(0,85)][Tooltip("The highest vertical angle that camera style 'FistPerson' camera can achieve.")]
   public float verticalAngle = 20.0f;
   [Range(0,40)][Tooltip("The maximum the camera can approximate your vision.")]
   public float maxScroolZoom = 30.0f;

   [Header("Custom Rotation Input")]
   [Tooltip("If this variable is true, the camera will only rotate when the key selected in the 'KeyToRotate' variable is pressed. If this variable is false, the camera can rotate freely, even without pressing any key.")]
   public bool rotateWhenClick = false;
   [Tooltip("Here you can select the button that must be pressed in order to rotate the camera.")]
   public string keyToRotate = "mouse 0";

   [Space(7)]
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertXInput = false;
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertYInput = false;
}
[Serializable]
public class MSACC_SettingsCameraFollow {
   [Header("Collision")]
   [Tooltip("If this variable is true, the camera ignores the colliders and crosses the walls freely.")]
   public bool ignoreCollision = false;

   [Header("Movement")]
   [Range(1,20)][Tooltip("The speed at which the camera can follow the player.")]
   public float displacementSpeed = 3.0f;

   [Header("Rotation")]
   [Tooltip("If this variable is true, the code makes a lookAt using quaternions.")]
   public bool customLookAt = false;
   [Range(1,30)][Tooltip("The speed at which the camera rotates as it follows and looks at the player.")]
   public float spinSpeedCustomLookAt = 15.0f;

   [Header("Use Scrool")]
   [Tooltip("If this variable is true, the 'FollowPlayer' camera style will have the player's distance affected by the mouse scrool. This will allow the player to zoom in or out of the camera.")]
   public bool useScrool = false;
   [Range(0.01f,2.0f)][Tooltip("The speed at which the player can zoom in and out of the camera.")]
   public float scroolSpeed = 1.0f;
   [Range(1,30)][Tooltip("The minimum distance the camera can be relative to the player.")]
   public float minDistance = 7.0f;
   [Range(1,200)][Tooltip("The maximum distance the camera can be relative to the player.")]
   public float maxDistance = 40.0f;
}
[Serializable]
public class MSACC_SettingsCameraOrbital {
   [Header("Settings")]
   [Range(0.01f,2.0f)][Tooltip("In this variable you can configure the sensitivity with which the script will perceive the movement of the X and Y inputs. ")]
   public float sensibility = 0.8f;
   [Range(0.01f,2.0f)][Tooltip("In this variable, you can configure the speed at which the orbital camera will approach or distance itself from the player when the mouse scrool is used.")]
   public float speedScrool = 1.0f;
   [Range(0.01f,2.0f)][Tooltip("In this variable, you can configure the speed at which the orbital camera moves up or down.")]
   public float speedYAxis = 0.5f;

   [Header("Limits")]
   [Range(3.0f,20.0f)][Tooltip("In this variable, you can set the minimum distance that the orbital camera can stay from the player.")]
   public float minDistance = 5.0f;
   [Range(20.0f,1000.0f)][Tooltip("In this variable, you can set the maximum distance that the orbital camera can stay from the player.")]
   public float maxDistance = 50.0f;
   [Range(-85,0)][Tooltip("In this variable it is possible to define the minimum angle that the camera can reach on the Y axis")]
   public float minAngleY = 0.0f;
   [Range(0,85)][Tooltip("In this variable it is possible to define the maximum angle that the camera can reach on the Y axis")]
   public float maxAngleY = 80.0f;
   [Tooltip("If this variable is true, the camera ignores the colliders and crosses the walls freely.")]
   public bool ignoreCollision = false;

   [Header("Custom Rotation Input")]
   [Tooltip("If this variable is true, the camera will only rotate when the key selected in the 'KeyToRotate' variable is pressed. If this variable is false, the camera can rotate freely, even without pressing any key.")]
   public bool rotateWhenClick = false;
   [Tooltip("Here you can select the button that must be pressed in order to rotate the camera.")]
   public string keyToRotate = "mouse 0";

   [Space(7)]
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertXInput = false;
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertYInput = false;
}
[Serializable]
public class MSACC_SettingsCameraOrbitalThatFollows {
   [Header("Settings(Follow)")]
   [Range(1,20)][Tooltip("The speed at which the camera can follow the player.")]
   public float displacementSpeed = 5.0f;
   [Tooltip("If this variable is true, the code makes a lookAt using quaternions.")]
   public bool customLookAt = false;
   [Range(1,30)][Tooltip("The speed at which the camera rotates as it follows and looks at the player.")]
   public float spinSpeedCustomLookAt = 15.0f;

   [Header("Settings(Orbital)")]
   [Range(0.01f,2.0f)][Tooltip("In this variable you can configure the sensitivity with which the script will perceive the movement of the X and Y inputs. ")]
   public float sensibility = 0.8f;
   [Range(0.01f,2.0f)][Tooltip("In this variable, you can configure the speed at which the orbital camera will approach or distance itself from the player when the mouse scrool is used.")]
   public float speedScrool = 1.0f;
   [Range(0.01f,2.0f)][Tooltip("In this variable, you can configure the speed at which the orbital camera moves up or down.")]
   public float speedYAxis = 0.5f;
   [Range(3.0f,20.0f)][Tooltip("In this variable, you can set the minimum distance that the orbital camera can stay from the player.")]
   public float minDistance = 5.0f;
   [Range(20.0f,1000.0f)][Tooltip("In this variable, you can set the maximum distance that the orbital camera can stay from the player.")]
   public float maxDistance = 50.0f;
   [Range(-85,0)][Tooltip("In this variable it is possible to define the minimum angle that the camera can reach on the Y axis")]
   public float minAngleY = 0.0f;
   [Range(0,85)][Tooltip("In this variable it is possible to define the maximum angle that the camera can reach on the Y axis")]
   public float maxAngleY = 80.0f;
   [Space(7)]
   [Tooltip("If this variable is true, the camera will only rotate when the key selected in the 'KeyToRotate' variable is pressed. If this variable is false, the camera can rotate freely, even without pressing any key.")]
   public bool rotateWhenClick = false;
   [Tooltip("Here you can select the button that must be pressed in order to rotate the camera.")]
   public string keyToRotate = "mouse 0";
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertXInput = false;
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertYInput = false;
   //
   public enum ResetTimeType { Time, Input_OnlyWindows }
   [Header("Settings(General)")]
   [Tooltip("In this variable it is possible to define how the control will be redefined for the camera that follows the player, through input or through a time.")]
   public ResetTimeType ResetControlType = ResetTimeType.Time;
   [Tooltip("If 'ResetControlType' is set to 'Input_OnlyWindows', the key that must be pressed to reset the control will be set by this variable.")]
   public KeyCode resetKey = KeyCode.Z;
   [Range(1.0f,50.0f)][Tooltip("If 'ResetControlType' is set to 'Time', the wait time for the camera to reset the control will be set by this variable.")]
   public float timeToReset = 8.0f;
   [Tooltip("If this variable is true, the camera ignores the colliders and crosses the walls freely.")]
   public bool ignoreCollision = false;
}
[Serializable]
public class MSACC_SettingsCameraETS_StyleCamera {
   [Header("Settings")]
   [Range(1,20)][Tooltip("Horizontal camera rotation sensitivity.")]
   public float sensibilityX = 10.0f;
   [Range(1,20)][Tooltip("Vertical camera rotation sensitivity.")]
   public float sensibilityY = 10.0f;
   [Range(0.5f,3.0f)][Tooltip("The distance the camera will move to the left when the mouse is also shifted to the left. This option applies only to cameras that have the 'ETS_StyleCamera' option selected.")]
   public float ETS_CameraShift = 1.0f;
   [Range(0,40)][Tooltip("The maximum the camera can approximate your vision.")]
   public float maxScroolZoom = 30.0f;
   [Range(0,1)][Tooltip("The speed with which the camera can approach your vision through the mouseScrool.")]
   public float speedScroolZoom = 0.5f;

   [Header("Custom Rotation Input")]
   [Tooltip("If this variable is true, the camera will only rotate when the key selected in the 'KeyToRotate' variable is pressed. If this variable is false, the camera can rotate freely, even without pressing any key.")]
   public bool rotateWhenClick = false;
   [Tooltip("Here you can select the button that must be pressed in order to rotate the camera.")]
   public string keyToRotate = "mouse 0";
   [Space(7)]
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertXInput = false;
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertYInput = false;
}
[Serializable]
public class MSACC_SettingsFlyCamera {
   [Header("Inputs")]
   [Tooltip("Here you can configure the 'Horizontal' inputs that should be used to move the camera 'CameraFly'.")]
   public string horizontalMove = "Horizontal";
   [Tooltip("Here you can configure the 'Vertical' inputs that should be used to move the camera 'CameraFly'.")]
   public string verticalMove = "Vertical";
   [Tooltip("Here you can configure the keys that must be pressed to accelerate the movement of the camera 'CameraFly'.")]
   public KeyCode speedKeyCode = KeyCode.LeftShift;
   [Tooltip("Here you can configure the key that must be pressed to move the camera 'CameraFly' up.")]
   public KeyCode moveUp = KeyCode.E;
   [Tooltip("Here you can configure the key that must be pressed to move the camera 'CameraFly' down.")]
   public KeyCode moveDown = KeyCode.Q;
   //
   [Header("Settings")]
   [Range(1,20)][Tooltip("Horizontal camera rotation sensitivity.")]
   public float sensibilityX = 10.0f;
   [Range(1,20)][Tooltip("Vertical camera rotation sensitivity.")]
   public float sensibilityY = 10.0f;
   [Range(1,100)][Tooltip("The speed of movement of this camera.")]
   public float movementSpeed = 20.0f;
   [Space(7)]
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertXInput = false;
   [Tooltip("If this variable is true, the X-axis input will be inverted.")]
   public bool invertYInput = false;
}

public class MSCameraController : MonoBehaviour {

   [Tooltip("Here you must associate the object that the cameras will follow. If you leave this variable empty, the cameras will follow the object in which this script was placed.")]
   public Transform target;

   [Space(7)][Tooltip("Here you must associate all the cameras that you want to control by this script, associating each one with an index and selecting your preferences.")]
   public MSACC_CameraType[] cameras = new MSACC_CameraType[0];
   [Tooltip("Here you can configure the cameras, deciding their speed of movement, rotation, zoom, among other options.")]
   public MSACC_CameraSetting CameraSettings;

   bool orbitalAtiv;
   bool orbital_AtivTemp;
   float rotacX = 0.0f;
   float rotacY = 0.0f;
   float tempoOrbit = 0.0f;
   float rotacXETS = 0.0f;
   float rotacYETS = 0.0f;

   Vector2 cameraRotationFly;
   bool changeCam;

   GameObject[] objPosicStopCameras;
   Quaternion[] originalRotation;
   GameObject[] originalPosition;
   Vector3[] originalPositionETS;
   float[] xOrbit;
   float[] yOrbit;
   float[] distanceFromOrbitalCamera;
   float[] initialFieldOfView;
   float[] camFollowPlayerDistance;

   int index = 0;
   int lastIndex = 0;

   Transform targetTransform;
   GameObject playerCamsObj;


   //global inputs
   [HideInInspector]
   public float _horizontalInputMSACC;
   [HideInInspector]
   public float _verticalInputMSACC;
   [HideInInspector]
   public float _scrollInputMSACC;
   [HideInInspector]
   public bool _enableMobileInputs;
   [HideInInspector]
   public int _mobileInputsIndex; // 0 = off,  1 = all,  2 = scroll buttons only

   void OnValidate (){
        if (cameras != null) {
            for (int x = 0; x < cameras.Length; x++) {
                if (cameras[x].volume == 0) {
                    cameras[x].volume = 1;
                }
            }
        }
   }

   void Awake(){

      if (target) {
         targetTransform = target;
      } else {
         targetTransform = transform;
      }

      GameObject temp = new GameObject ("PlayerCams");
      temp.transform.parent = targetTransform;
      objPosicStopCameras = new GameObject[cameras.Length];
      originalRotation = new Quaternion[cameras.Length];
      originalPosition = new GameObject[cameras.Length];
      originalPositionETS = new Vector3[cameras.Length];
      xOrbit = new float[cameras.Length];
      yOrbit = new float[cameras.Length];

      distanceFromOrbitalCamera = new float[cameras.Length];
      initialFieldOfView = new float[cameras.Length];
      camFollowPlayerDistance = new float[cameras.Length];

      changeCam = false;
      orbitalAtiv = false;
      orbital_AtivTemp = false;

      for (int x = 0; x < cameras.Length; x++) {
         if (cameras [x]._camera) {
            if (cameras [x].volume == 0) {
               cameras [x].volume = 1;
            }
            initialFieldOfView [x] = cameras [x]._camera.fieldOfView;

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FirstPerson) {
               cameras [x]._camera.transform.parent = temp.transform;
               originalRotation [x] = cameras [x]._camera.transform.localRotation;
            }


            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FollowPlayer) {
               cameras [x]._camera.transform.parent = temp.transform;
               originalPosition [x] = new GameObject ("positionFollowPlayerCamera" + x);
               originalPosition [x].transform.parent = temp.transform;
               originalPosition [x].transform.position = cameras [x]._camera.transform.position;
               if (CameraSettings.ajustTheLayers) {
                  targetTransform.gameObject.layer = 2;
                  foreach (Transform trans in targetTransform.gameObject.GetComponentsInChildren<Transform>(true)) {
                     trans.gameObject.layer = 2;
                  }
               }
               camFollowPlayerDistance [x] = Vector3.Distance (cameras [x]._camera.transform.position, targetTransform.position);
               cam
            }

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.Orbital) {
               cameras [x]._camera.transform.parent = temp.transform;
               cameras [x]._camera.transform.LookAt (target);
               xOrbit [x] = cameras [x]._camera.transform.eulerAngles.y;
               yOrbit [x] = cameras [x]._camera.transform.eulerAngles.x;
               if (CameraSettings.ajustTheLayers) {
                  targetTransform.gameObject.layer = 2;
                  foreach (Transform trans in targetTransform.gameObject.GetComponentsInChildren<Transform>(true)) {
                     trans.gameObject.layer = 2;
                  }
               }
            }
            distanceFromOrbitalCamera [x] = Vector3.Distance (cameras [x]._camera.transform.position, targetTransform.position);
            distanceFromOrbitalCamera [x] = Mathf.Clamp (distanceFromOrbitalCamera [x], CameraSettings.orbital.minDistance, CameraSettings.orbital.maxDistance);

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.Stop) {
               cameras [x]._camera.transform.parent = temp.transform;
            }

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.StraightStop) {
               cameras [x]._camera.transform.parent = temp.transform;
               objPosicStopCameras [x] = new GameObject ("positionStraightStopCamera" + x);
               objPosicStopCameras [x].transform.parent = cameras [x]._camera.transform;
               objPosicStopCameras [x].transform.localPosition = new Vector3 (0, 0, 1.0f);
               objPosicStopCameras [x].transform.parent = temp.transform;
            }

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.OrbitalThatFollows) {
               cameras [x]._camera.transform.parent = temp.transform;
               xOrbit [x] = cameras [x]._camera.transform.eulerAngles.x;
               yOrbit [x] = cameras [x]._camera.transform.eulerAngles.y;

               originalPosition [x] = new GameObject ("positionCameraFollowPlayer" + x);
               originalPosition [x].transform.parent = temp.transform;
               originalPosition [x].transform.position = cameras [x]._camera.transform.position;

               if (CameraSettings.ajustTheLayers) {
                  targetTransform.gameObject.layer = 2;
                  foreach (Transform trans in targetTransform.gameObject.GetComponentsInChildren<Transform>(true)) {
                     trans.gameObject.layer = 2;
                  }
               }
            }

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.ETS_StyleCamera) {
               cameras [x]._camera.transform.parent = temp.transform;
               originalRotation [x] = cameras [x]._camera.transform.localRotation;
               originalPositionETS [x] = cameras [x]._camera.transform.localPosition;
            }

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FlyCamera_OnlyWindows) {
               cameras [x]._camera.transform.parent = null;
            }

            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.LookAtThePlayer) {
               cameras [x]._camera.transform.parent = null;
            }

            AudioListener audListner = cameras [x]._camera.GetComponent<AudioListener> ();
            if (audListner == null) {
               cameras [x]._camera.transform.gameObject.AddComponent (typeof(AudioListener));
            }

         } else {
            Debug.LogWarning ("There is no camera associated with the index " + x);
         }
      }
      playerCamsObj = temp;
      //
      if (CameraSettings.followPlayer.minDistance > CameraSettings.followPlayer.maxDistance) {
         CameraSettings.followPlayer.minDistance = 15;
         CameraSettings.followPlayer.maxDistance = 15;
         Debug.LogWarning ("The minimum distance from the 'FollowPlayer' camera is greater than the maximum distance, and this may cause errors.");
      }
   }

   void Start(){
      index = 0;
      lastIndex = 0;
      _enableMobileInputs = false;
      EnableCameras (index);
   }

   void EnableCameras (int index){
      if (cameras.Length > 0) {
         changeCam = true;
         for (int x = 0; x < cameras.Length; x++) {
            if (cameras [x]._camera) {
               if (x == index) {
                  cameras [x]._camera.gameObject.SetActive (true);
                  //
                  if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FirstPerson) {
                     rotacX = 0.0f;
                     rotacY = 0.0f;
                  }
                  if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.OrbitalThatFollows) {
                     tempoOrbit = 0.0f;
                  }
                  if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.ETS_StyleCamera) {
                     rotacXETS = 0.0f;
                     rotacYETS = 0.0f;
                  }
                  if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FlyCamera_OnlyWindows) {
                     cameras [x]._camera.transform.position = cameras [lastIndex]._camera.transform.position;
                     cameraRotationFly = new Vector2(cameras [lastIndex]._camera.transform.eulerAngles.y, 0);
                  }
               } else {
                  cameras [x]._camera.gameObject.SetActive (false);
               }
            }
         }
      }
   }

   void ManageCameras(){
      if (changeCam) {
         changeCam = false;
         for (int x = 0; x < cameras.Length; x++) {
            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FollowPlayer) {
               if (cameras [x]._camera.isActiveAndEnabled) {
                  cameras [x]._camera.transform.parent = null;
               } else {
                  cameras [x]._camera.transform.parent = playerCamsObj.transform;
               }
            }
            //
            if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.Orbital || cameras [x].rotationType == MSACC_CameraType.TipoRotac.OrbitalThatFollows) {
               cameras [x]._camera.transform.LookAt (target);
               xOrbit [x] = cameras [x]._camera.transform.eulerAngles.y;
               yOrbit [x] = cameras [x]._camera.transform.eulerAngles.x;
               distanceFromOrbitalCamera [x] = Vector3.Distance (cameras [x]._camera.transform.position, targetTransform.position);
               distanceFromOrbitalCamera [x] = Mathf.Clamp (distanceFromOrbitalCamera [x], CameraSettings.orbital.minDistance, CameraSettings.orbital.maxDistance);
            }
         }

         //set on/off mobile inputs
         if (cameras [index].rotationType == MSACC_CameraType.TipoRotac.Stop || cameras [index].rotationType == MSACC_CameraType.TipoRotac.StraightStop ||
            cameras [index].rotationType == MSACC_CameraType.TipoRotac.LookAtThePlayer || cameras [index].rotationType == MSACC_CameraType.TipoRotac.FlyCamera_OnlyWindows) {
            _mobileInputsIndex = 0; // 0 = all mobile inputs off
         }
         if (cameras [index].rotationType == MSACC_CameraType.TipoRotac.FirstPerson || cameras [index].rotationType == MSACC_CameraType.TipoRotac.ETS_StyleCamera ||
            cameras [index].rotationType == MSACC_CameraType.TipoRotac.Orbital || cameras [index].rotationType == MSACC_CameraType.TipoRotac.OrbitalThatFollows) {
            _mobileInputsIndex = 1; // 1 = all mobile inputs on
         }
         if (cameras [index].rotationType == MSACC_CameraType.TipoRotac.FollowPlayer) {
            _mobileInputsIndex = 2; // 2 = scroll buttons only
         }
      }

      AudioListener.volume = cameras [index].volume;
      float timeScaleSpeed = Mathf.Clamp (1.0f / Time.timeScale, 0.01f, 1);
      switch (cameras[index].rotationType ) {
      case MSACC_CameraType.TipoRotac.Stop:
         //stop camera
         break;
      case MSACC_CameraType.TipoRotac.StraightStop:
         Quaternion linearRotation = Quaternion.LookRotation(objPosicStopCameras[index].transform.position - cameras [index]._camera.transform.position, Vector3.up);
         cameras [index]._camera.transform.rotation = Quaternion.Slerp(cameras [index]._camera.transform.rotation, linearRotation, Time.deltaTime * 15.0f);
         break;
      case MSACC_CameraType.TipoRotac.LookAtThePlayer:
         cameras [index]._camera.transform.LookAt (targetTransform.position);
         break;
      case MSACC_CameraType.TipoRotac.FirstPerson:
         //getInputs
         float xInput = _horizontalInputMSACC;
         float yInput = _verticalInputMSACC;
         if (CameraSettings.firstPerson.invertXInput) {
            xInput = -_horizontalInputMSACC;
         }
         if (CameraSettings.firstPerson.invertYInput) {
            yInput = -_verticalInputMSACC;
         }
         if (CameraSettings.firstPerson.rotateWhenClick) {
            if (Input.GetKey (CameraSettings.firstPerson.keyToRotate) || _enableMobileInputs) {
               rotacX += xInput * CameraSettings.firstPerson.sensibilityX;
               rotacY += yInput * CameraSettings.firstPerson.sensibilityY;
            }
         } else {
            rotacX += xInput * CameraSettings.firstPerson.sensibilityX;
            rotacY += yInput * CameraSettings.firstPerson.sensibilityY;
         }
         //
         rotacX = ClampAngle (rotacX, -CameraSettings.firstPerson.horizontalAngle, CameraSettings.firstPerson.horizontalAngle);
         rotacY = ClampAngle (rotacY, -CameraSettings.firstPerson.verticalAngle, CameraSettings.firstPerson.verticalAngle);
         Quaternion xQuaternion = Quaternion.AngleAxis (rotacX, Vector3.up);
         Quaternion yQuaternion = Quaternion.AngleAxis (rotacY, -Vector3.right);
         Quaternion _nextRot = originalRotation [index] * xQuaternion * yQuaternion;
         cameras [index]._camera.transform.localRotation = Quaternion.Lerp (cameras [index]._camera.transform.localRotation, _nextRot, Time.deltaTime * 10.0f * timeScaleSpeed);
         //fieldOfView
         cameras [index]._camera.fieldOfView -= _scrollInputMSACC * CameraSettings.firstPerson.speedScroolZoom * 50.0f;
         if (cameras [index]._camera.fieldOfView < (initialFieldOfView [index] - CameraSettings.firstPerson.maxScroolZoom)) {
            cameras [index]._camera.fieldOfView = (initialFieldOfView [index] - CameraSettings.firstPerson.maxScroolZoom);
         }
         if (cameras [index]._camera.fieldOfView > initialFieldOfView [index]) {
            cameras [index]._camera.fieldOfView = (initialFieldOfView [index]);
         }
         break;
      case MSACC_CameraType.TipoRotac.FollowPlayer:
         //move
         RaycastHit hitCamFollow;
         if (CameraSettings.followPlayer.useScrool) {
            float camLerpSpeed = Time.deltaTime * CameraSettings.followPlayer.displacementSpeed * (camFollowPlayerDistance [index] * 0.1f);
            camFollowPlayerDistance [index] = camFollowPlayerDistance [index] - _scrollInputMSACC * (CameraSettings.followPlayer.scroolSpeed * 50.0f);
            camFollowPlayerDistance [index] = Mathf.Clamp (camFollowPlayerDistance [index], CameraSettings.followPlayer.minDistance, CameraSettings.followPlayer.maxDistance);
            Vector3 direction = (targetTransform.position - originalPosition [index].transform.position).normalized;
            Vector3 finalPos = targetTransform.position - direction * camFollowPlayerDistance [index];
            //
            if (!Physics.Linecast (targetTransform.position, finalPos)) {
               cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, finalPos, camLerpSpeed);
            } else if (Physics.Linecast (targetTransform.position, finalPos, out hitCamFollow)) {
               if (CameraSettings.followPlayer.ignoreCollision) {
                  cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, finalPos, camLerpSpeed);
               } else {
                  cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, hitCamFollow.point, camLerpSpeed);
               }
            }
         } else {
            if (!Physics.Linecast (targetTransform.position, originalPosition [index].transform.position)) {
               cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, originalPosition [index].transform.position, Time.deltaTime * CameraSettings.followPlayer.displacementSpeed);
            } else if (Physics.Linecast (transform.position, originalPosition [index].transform.position, out hitCamFollow)) {
               if (CameraSettings.followPlayer.ignoreCollision) {
                  cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, originalPosition [index].transform.position, Time.deltaTime * CameraSettings.followPlayer.displacementSpeed);
               } else {
                  cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, hitCamFollow.point, Time.deltaTime * CameraSettings.followPlayer.displacementSpeed);
               }
            }
         }
         //rotation
         if (CameraSettings.followPlayer.customLookAt) {
            Quaternion nextRotation = Quaternion.LookRotation (targetTransform.position - cameras [index]._camera.transform.position, Vector3.up);
            cameras [index]._camera.transform.rotation = Quaternion.Slerp (cameras [index]._camera.transform.rotation, nextRotation, Time.deltaTime * CameraSettings.followPlayer.spinSpeedCustomLookAt);
         } else {
            cameras [index]._camera.transform.LookAt (targetTransform.position);
         }
         break;
      case MSACC_CameraType.TipoRotac.Orbital:
         //raycast hit
         RaycastHit hitCamOrbital;
         float minDistance = CameraSettings.orbital.minDistance;
         if (Physics.Linecast (targetTransform.position, cameras [index]._camera.transform.position, out hitCamOrbital)) {
            if (!CameraSettings.orbital.ignoreCollision) {
               distanceFromOrbitalCamera [index] = Vector3.Distance (targetTransform.position, hitCamOrbital.point);
               minDistance = Mathf.Clamp (distanceFromOrbitalCamera [index], minDistance * 0.5f, CameraSettings.orbital.maxDistance);
            }
         }
         //getInputs
         float xInputOrb = _horizontalInputMSACC;
         float yInputOrb = _verticalInputMSACC;
         if (CameraSettings.orbital.invertXInput) {
            xInputOrb = -_horizontalInputMSACC;
         }
         if (CameraSettings.orbital.invertYInput) {
            yInputOrb = -_verticalInputMSACC;
         }
         if (CameraSettings.orbital.rotateWhenClick) {
            if (Input.GetKey (CameraSettings.orbital.keyToRotate) || _enableMobileInputs) {
               xOrbit [index] += xInputOrb * (CameraSettings.orbital.sensibility * distanceFromOrbitalCamera [index]) / (distanceFromOrbitalCamera [index] * 0.5f);
               yOrbit [index] -= yInputOrb * CameraSettings.orbital.sensibility * (CameraSettings.orbital.speedYAxis * 10.0f);
            }
         } else {
            xOrbit [index] += xInputOrb * (CameraSettings.orbital.sensibility * distanceFromOrbitalCamera [index]) / (distanceFromOrbitalCamera [index] * 0.5f);
            yOrbit [index] -= yInputOrb * CameraSettings.orbital.sensibility * (CameraSettings.orbital.speedYAxis * 10.0f);
         }
         //move - rotation
         yOrbit [index] = ClampAngle (yOrbit [index], CameraSettings.orbital.minAngleY, CameraSettings.orbital.maxAngleY);
         Quaternion quatToEuler = Quaternion.Euler (yOrbit [index], xOrbit [index], 0);
         distanceFromOrbitalCamera [index] = Mathf.Clamp (distanceFromOrbitalCamera [index] - _scrollInputMSACC * (CameraSettings.orbital.speedScrool * 50.0f), minDistance, CameraSettings.orbital.maxDistance);
         Vector3 zPosition = new Vector3 (0.0f, 0.0f, -distanceFromOrbitalCamera [index]);
         Vector3 nextPosCam = quatToEuler * zPosition + targetTransform.position;
         Vector3 currentPosCam = cameras [index]._camera.transform.position;
         Quaternion camRotation = cameras [index]._camera.transform.rotation;
         cameras [index]._camera.transform.rotation = Quaternion.Lerp(camRotation, quatToEuler, Time.deltaTime * 5.0f * timeScaleSpeed);
         cameras [index]._camera.transform.position = Vector3.Lerp(currentPosCam, nextPosCam, Time.deltaTime * 5.0f * timeScaleSpeed);
         break;
      case MSACC_CameraType.TipoRotac.OrbitalThatFollows:
         float movXInput = 0.0f;
         float movYInput = 0.0f;
         float movZInput = _scrollInputMSACC;
         if (CameraSettings.OrbitalThatFollows.rotateWhenClick) {
            if (Input.GetKey (CameraSettings.OrbitalThatFollows.keyToRotate) || _enableMobileInputs) {
               movXInput = _horizontalInputMSACC;
               movYInput = _verticalInputMSACC;
               if (CameraSettings.OrbitalThatFollows.invertXInput) {
                  movXInput = -_horizontalInputMSACC;
               }
               if (CameraSettings.OrbitalThatFollows.invertYInput) {
                  movYInput = -_verticalInputMSACC;
               }
            }
         } else {
            movXInput = _horizontalInputMSACC;
            movYInput = _verticalInputMSACC;
            if (CameraSettings.OrbitalThatFollows.invertXInput) {
               movXInput = -_horizontalInputMSACC;
            }
            if (CameraSettings.OrbitalThatFollows.invertYInput) {
               movYInput = -_verticalInputMSACC;
            }
         }
         //
         if (movXInput > 0.0f || movYInput > 0.0f || movZInput > 0.0f) {
            orbitalAtiv = true;
            tempoOrbit = 0.0f;
            if (!orbital_AtivTemp) {
               orbital_AtivTemp = true;
               xOrbit [index] = cameras [index]._camera.transform.eulerAngles.y;
               yOrbit [index] = cameras [index]._camera.transform.eulerAngles.x;
            }
         } else {
            tempoOrbit += Time.deltaTime;
            if (tempoOrbit > CameraSettings.OrbitalThatFollows.timeToReset) {
               tempoOrbit = CameraSettings.OrbitalThatFollows.timeToReset + 0.1f;
            }
         }
         //
         switch (CameraSettings.OrbitalThatFollows.ResetControlType) {
         case MSACC_SettingsCameraOrbitalThatFollows.ResetTimeType.Time:
            if (tempoOrbit > CameraSettings.OrbitalThatFollows.timeToReset) {
               orbitalAtiv = false;
               orbital_AtivTemp = false;
            }
            break;
         case MSACC_SettingsCameraOrbitalThatFollows.ResetTimeType.Input_OnlyWindows:
            if (Input.GetKeyDown(CameraSettings.OrbitalThatFollows.resetKey)) {
               orbitalAtiv = false;
               orbital_AtivTemp = false;
            }
            break;
         }
         //
         RaycastHit hitCamOTS;
         if(orbitalAtiv == true){
            float _minDistance = CameraSettings.OrbitalThatFollows.minDistance;
            if (Physics.Linecast (targetTransform.position, cameras [index]._camera.transform.position, out hitCamOTS)) {
               if (!CameraSettings.OrbitalThatFollows.ignoreCollision) {
                  distanceFromOrbitalCamera [index] = Vector3.Distance (targetTransform.position, hitCamOTS.point);
                  _minDistance = Mathf.Clamp (distanceFromOrbitalCamera [index], _minDistance * 0.5f, CameraSettings.OrbitalThatFollows.maxDistance);
               }
            }
            xOrbit [index] += movXInput * (CameraSettings.OrbitalThatFollows.sensibility * distanceFromOrbitalCamera [index]) / (distanceFromOrbitalCamera [index] * 0.5f);
            yOrbit [index] -= movYInput * CameraSettings.OrbitalThatFollows.sensibility * (CameraSettings.OrbitalThatFollows.speedYAxis * 10.0f);
            yOrbit [index] = ClampAngle (yOrbit [index], CameraSettings.OrbitalThatFollows.minAngleY, CameraSettings.OrbitalThatFollows.maxAngleY);
            Quaternion quaterToEuler = Quaternion.Euler (yOrbit [index], xOrbit [index], 0);
            distanceFromOrbitalCamera [index] = Mathf.Clamp (distanceFromOrbitalCamera [index] - movZInput * (CameraSettings.OrbitalThatFollows.speedScrool * 50.0f), _minDistance, CameraSettings.OrbitalThatFollows.maxDistance);
            Vector3 _zPosition = new Vector3 (0.0f, 0.0f, -distanceFromOrbitalCamera [index]);
            Vector3 _camNewPos = quaterToEuler * _zPosition + targetTransform.position;
            Vector3 _camCurrentPos = cameras [index]._camera.transform.position;
            Quaternion camRot = cameras [index]._camera.transform.rotation;
            cameras [index]._camera.transform.rotation = Quaternion.Lerp (camRot, quaterToEuler, Time.deltaTime * 5.0f * timeScaleSpeed);
            cameras [index]._camera.transform.position = Vector3.Lerp (_camCurrentPos, _camNewPos, Time.deltaTime * 5.0f * timeScaleSpeed);
         } else {
            if (!Physics.Linecast (targetTransform.position, originalPosition [index].transform.position)) {
               cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, originalPosition [index].transform.position, Time.deltaTime * CameraSettings.OrbitalThatFollows.displacementSpeed);
            }
            else if(Physics.Linecast(targetTransform.position, originalPosition [index].transform.position,out hitCamOTS)){
               if (CameraSettings.OrbitalThatFollows.ignoreCollision) {
                  cameras [index]._camera.transform.position = Vector3.Lerp (cameras [index]._camera.transform.position, originalPosition [index].transform.position, Time.deltaTime * CameraSettings.OrbitalThatFollows.displacementSpeed);
               }
               else {
                  cameras [index]._camera.transform.position = Vector3.Lerp(cameras [index]._camera.transform.position, hitCamOTS.point,Time.deltaTime * CameraSettings.OrbitalThatFollows.displacementSpeed);
               }
            }
            //
            if (CameraSettings.OrbitalThatFollows.customLookAt) {
               Quaternion quatLookRot = Quaternion.LookRotation (targetTransform.position - cameras [index]._camera.transform.position, Vector3.up);
               cameras [index]._camera.transform.rotation = Quaternion.Slerp (cameras [index]._camera.transform.rotation, quatLookRot, Time.deltaTime * CameraSettings.OrbitalThatFollows.spinSpeedCustomLookAt);
            } else {
               cameras [index]._camera.transform.LookAt (targetTransform.position);
            }
         }
         break;
      case MSACC_CameraType.TipoRotac.ETS_StyleCamera:
         float xInputEts = _horizontalInputMSACC;
         float yInputEts = _verticalInputMSACC;
         if (CameraSettings.ETS_StyleCamera.invertXInput) {
            xInputEts = -_horizontalInputMSACC;
         }
         if (CameraSettings.ETS_StyleCamera.invertYInput) {
            yInputEts = -_verticalInputMSACC;
         }
         if (CameraSettings.ETS_StyleCamera.rotateWhenClick) {
            if (Input.GetKey (CameraSettings.ETS_StyleCamera.keyToRotate) || _enableMobileInputs) {
               rotacXETS += xInputEts * CameraSettings.ETS_StyleCamera.sensibilityX;
               rotacYETS += yInputEts * CameraSettings.ETS_StyleCamera.sensibilityY;
            }
         } else {
            rotacXETS += xInputEts * CameraSettings.ETS_StyleCamera.sensibilityX;
            rotacYETS += yInputEts * CameraSettings.ETS_StyleCamera.sensibilityY;
         }
         Vector3 newPositionETS = new Vector3 (originalPositionETS [index].x + Mathf.Clamp (rotacXETS / 50 + (CameraSettings.ETS_StyleCamera.ETS_CameraShift/3.0f), -CameraSettings.ETS_StyleCamera.ETS_CameraShift, 0), originalPositionETS [index].y, originalPositionETS [index].z);
         cameras [index]._camera.transform.localPosition = Vector3.Lerp (cameras [index]._camera.transform.localPosition, newPositionETS, Time.deltaTime * 10.0f);
         rotacXETS = ClampAngle (rotacXETS, -180, 80);
         rotacYETS = ClampAngle (rotacYETS, -60, 60);
         Quaternion _xQuaternion = Quaternion.AngleAxis (rotacXETS, Vector3.up);
         Quaternion _yQuaternion = Quaternion.AngleAxis (rotacYETS, -Vector3.right);
         Quaternion nextRot = originalRotation [index] * _xQuaternion * _yQuaternion;
         cameras [index]._camera.transform.localRotation = Quaternion.Lerp (cameras [index]._camera.transform.localRotation, nextRot, Time.deltaTime * 10.0f * timeScaleSpeed);
         //fieldOfView
         cameras [index]._camera.fieldOfView -= _scrollInputMSACC * CameraSettings.ETS_StyleCamera.speedScroolZoom * 50.0f;
         if (cameras [index]._camera.fieldOfView < (initialFieldOfView [index] - CameraSettings.ETS_StyleCamera.maxScroolZoom)) {
            cameras [index]._camera.fieldOfView = (initialFieldOfView [index] - CameraSettings.ETS_StyleCamera.maxScroolZoom);
         }
         if (cameras [index]._camera.fieldOfView > initialFieldOfView [index]) {
            cameras [index]._camera.fieldOfView = (initialFieldOfView [index]);
         }
         break;
      case MSACC_CameraType.TipoRotac.FlyCamera_OnlyWindows:
         float xInputFly = _horizontalInputMSACC;
         float yInputFly = _verticalInputMSACC;
         if (CameraSettings.FlyCamera_OnlyWindows.invertXInput) {
            xInputFly = -_horizontalInputMSACC;
         }
         if (CameraSettings.FlyCamera_OnlyWindows.invertYInput) {
            yInputFly = -_verticalInputMSACC;
         }
         //
         cameraRotationFly.x += xInputFly * CameraSettings.FlyCamera_OnlyWindows.sensibilityX * 15 * Time.deltaTime;
         cameraRotationFly.y += yInputFly * CameraSettings.FlyCamera_OnlyWindows.sensibilityY * 15 * Time.deltaTime;
         cameraRotationFly.y = Mathf.Clamp (cameraRotationFly.y, -90, 90);
         cameras [index]._camera.transform.rotation = Quaternion.AngleAxis (cameraRotationFly.x, Vector3.up);
         cameras [index]._camera.transform.rotation *= Quaternion.AngleAxis (cameraRotationFly.y, Vector3.left);
         //
         float speedCamFly = CameraSettings.FlyCamera_OnlyWindows.movementSpeed;
         if (Input.GetKey (CameraSettings.FlyCamera_OnlyWindows.speedKeyCode)) {
            speedCamFly *= 3.0f;
         }
         cameras [index]._camera.transform.position += cameras [index]._camera.transform.right * speedCamFly * Input.GetAxis(CameraSettings.FlyCamera_OnlyWindows.horizontalMove) * Time.deltaTime;
         cameras [index]._camera.transform.position += cameras [index]._camera.transform.forward * speedCamFly * Input.GetAxis(CameraSettings.FlyCamera_OnlyWindows.verticalMove) * Time.deltaTime;
         //
         if(Input.GetKey(CameraSettings.FlyCamera_OnlyWindows.moveUp)){
            cameras [index]._camera.transform.position += Vector3.up * speedCamFly * Time.deltaTime;
         }
         if(Input.GetKey(CameraSettings.FlyCamera_OnlyWindows.moveDown)){
            cameras [index]._camera.transform.position -= Vector3.up * speedCamFly * Time.deltaTime;
         }
         break;
      }
   }

   public static float ClampAngle (float angle, float min, float max){
      if (angle < -360F) { angle += 360F; }
      if (angle > 360F) { angle -= 360F; }
      return Mathf.Clamp (angle, min, max);
   }
   
   public void MSADCCChangeCameras(){ //use this void to change cameras using buttons
      if (Time.timeScale > 0) {
         if (index < (cameras.Length - 1)) {
            lastIndex = index;
            index++;
            EnableCameras (index);
         } else if (index >= (cameras.Length - 1)) {
            lastIndex = index;
            index = 0;
            EnableCameras (index);
         }
      }
   }

   void Update(){
      
      // Get inputs
      if (!_enableMobileInputs) {
         _horizontalInputMSACC = Input.GetAxis (CameraSettings.inputMouseX);
         _verticalInputMSACC = Input.GetAxis (CameraSettings.inputMouseY);
         _scrollInputMSACC = Input.GetAxis (CameraSettings.inputMouseScrollWheel);
      } else {
         //GetComponent<MSCameraController>()._horizontalInputMSACC = InputX;
         //GetComponent<MSCameraController>()._verticalInputMSACC = InputY;
         //GetComponent<MSCameraController>()._scrollInputMSACC = InputScroll;
      }
      _horizontalInputMSACC = Mathf.Clamp (_horizontalInputMSACC, -1, 1);
      _verticalInputMSACC = Mathf.Clamp (_verticalInputMSACC, -1, 1);
      _scrollInputMSACC = Mathf.Clamp (_scrollInputMSACC, -1, 1);
      //


      //camera switch key
      if (!_enableMobileInputs) {
         if (Time.timeScale > 0) {
            if (Input.GetKeyDown (CameraSettings.cameraSwitchKey) && index < (cameras.Length - 1)) {
               lastIndex = index;
               index++;
               EnableCameras (index);
            } else if (Input.GetKeyDown (CameraSettings.cameraSwitchKey) && index >= (cameras.Length - 1)) {
               lastIndex = index;
               index = 0;
               EnableCameras (index);
            }
         }
      }


      //update cameras
      if (CameraSettings.camerasUpdateMode == MSACC_CameraSetting.UpdateMode.Update) {
         if (cameras.Length > 0 && Time.timeScale > 0) {
            if (cameras [index]._camera) {
               ManageCameras ();
            }
         }
      }
   }

   void LateUpdate(){
      //update cameras
      if (CameraSettings.camerasUpdateMode == MSACC_CameraSetting.UpdateMode.LateUpdate) {
         if (cameras.Length > 0 && Time.timeScale > 0) {
            if (cameras [index]._camera) {
               ManageCameras ();
            }
         }
      }
   }

   void FixedUpdate(){
      //update cameras
      if (CameraSettings.camerasUpdateMode == MSACC_CameraSetting.UpdateMode.FixedUpdate) {
         if (cameras.Length > 0 && Time.timeScale > 0) {
            if (cameras [index]._camera) {
               ManageCameras ();
            }
         }
      }
   }
}

saccasolutions
Iniciante
Iniciante

PONTOS : 139
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por Fagner em Seg Maio 11, 2020 11:16 pm

I'm on my phone, it's hard to tell you the number of the line, but after the class name, there a property called target, you can declare your Vector3 offset after that. 
In the ManageCameras()
There's a line:
camera[x]._camera.transform.LookAt(target);
Just change the code adding a +offset.

You should look if there's another line like this one, and change the code too, use the search in your code editor (LookAt) 

Another option is to use a gameobject as target, drag it to the avatar hierarchy, preferably being the first child object. 
Look at the Awake () function, you can set the target using:
Target = transform.GetChild(index of object in hierarchy):

@MarcosSchultz, dá uma olhada aqui, veja se é só isso mesmo
Fagner
Fagner
Moderador

Masculino PONTOS : 2279
REPUTAÇÃO : 409
Áreas de atuação : Modelagem 3D, Programação.
Respeito as regras : Camera Height  Aad8pUi

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por MarcosSchultz em Ter Maio 12, 2020 3:07 am

Hello. The code has a variable in the inspector called 'Target'. It is the first variable that appears. Just associate in this variable the object that the camera must follow.

Try to create an empty object (your player's child) and adjust it to the position of your player's head, and after that, associate this object in the 'target' variable.
MarcosSchultz
MarcosSchultz
Administrador

Masculino PONTOS : 63080
REPUTAÇÃO : 2488
Idade : 24
Áreas de atuação : Administrador do fórum
Respeito as regras : Camera Height  Aad8pUi

https://www.schultzgames.com

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions em Ter Maio 12, 2020 11:03 pm

@MarcosSchultz escreveu:Hello. The code has a variable in the inspector called 'Target'. It is the first variable that appears. Just associate in this variable the object that the camera must follow.

Try to create an empty object (your player's child) and adjust it to the position of your player's head, and after that, associate this object in the 'target' variable.
Yes, except I am using an UMA avatar with an idle animation so the camera moves and sways with any body part I try and attach the camera to.

saccasolutions
Iniciante
Iniciante

PONTOS : 139
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions em Ter Maio 12, 2020 11:08 pm

@Fagner escreveu: I'm on my phone, it's hard to tell you the number of the line, but after the class name, there a property called target, you can declare your Vector3 offset after that. 
In the ManageCameras ()
There's a line:
camera [x] ._ camera.transform.LookAt (target);
Just change the code adding a + offset.

You should look if there's another line like this one, and change the code too, use the search in your code editor (LookAt) 

Another option is to use a gameobject as target, drag it to the avatar hierarchy, preferably being the first child object . 
Look at the Awake () function, you can set the target using:
Target = transform.GetChild (index of object in hierarchy):

@MarcosSchultz, take a look here, see if that's it
i found the line of the code, however I am a VERY new C programmer. Can you help with the correct syntax for the offset?

I'm thinking it could go here:
Código:
case MSACC_CameraType.TipoRotac.LookAtThePlayer:
         cameras [index]._camera.transform.LookAt (targetTransform.position);
            
         break;

or where you suggested (using follow player), somewhere here:
Código:
if (cameras [x].rotationType == MSACC_CameraType.TipoRotac.FollowPlayer) {
               cameras [x]._camera.transform.parent = temp.transform;
               originalPosition [x] = new GameObject ("positionFollowPlayerCamera" + x);
               originalPosition [x].transform.parent = temp.transform;
               originalPosition [x].transform.position = cameras [x]._camera.transform.position;
               if (CameraSettings.ajustTheLayers) {
                  targetTransform.gameObject.layer = 2;
                  foreach (Transform trans in targetTransform.gameObject.GetComponentsInChildren<Transform>(true)) {
                     trans.gameObject.layer = 2;
                  }
               }
               camFollowPlayerDistance [x] = Vector3.Distance (cameras [x]._camera.transform.position, targetTransform.position);

saccasolutions
Iniciante
Iniciante

PONTOS : 139
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions em Qua Maio 13, 2020 12:08 am

Ok so that was easy! I thought maybe I would need to hardcose the coordinates, I did not realize it would add the editing to the editor! So... that gives me the ability to tilt the camera up, but how do I RAISE it? The camera itself is still sitting at the same level of the avatars feet.

saccasolutions
Iniciante
Iniciante

PONTOS : 139
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Voltar ao Topo Ir em baixo

DÚVIDA Re: Camera Height

Mensagem por Fagner em Qua Maio 13, 2020 3:41 am

I've made a simple script to add the offset on the LateUpdate() and restore the original position On Update(). this should work with MarcosSchultz original script.
You need to change your script execution order to make sure my script is the last executed.

https://docs.unity3d.com/Manual/class-MonoManager.html

Camera Height  ZP7kp36

Código:
using UnityEngine;

public class CameraOffset : MonoBehaviour
{
    public Transform cameraT;
    public Transform target;
    public Vector3 offsetCam, offsetTarget;

    private Vector3 lastposition;
    private Quaternion lastRotation;

    private void Update()
    {
        cameraT.position = lastposition;
        cameraT.rotation = lastRotation;
    }

    private void LateUpdate()
    {
        lastposition = cameraT.position;
        lastRotation = cameraT.rotation;

        cameraT.position += offsetCam;
        cameraT.LookAt(target.position + offsetTarget);
    }
}

Fagner
Fagner
Moderador

Masculino PONTOS : 2279
REPUTAÇÃO : 409
Áreas de atuação : Modelagem 3D, Programação.
Respeito as regras : Camera Height  Aad8pUi

Voltar ao Topo Ir em baixo

Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum