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 resolver problema da mesh não renderizar após fazer a build
RANDOMIZAR ATAQUES
[TUTORIAL] Escolher a quantos FPS (fixos) o seu jogo deverá rodar.
Pontuação na tela de Game Over
Personagem dentro da agua
[Resolvido]Sript de pegar itens no cenario
[TUTORIAL] Campo de visão dos inimigos (Enemy FOV) com Raycast ou OverlapSphere
Fazer o Player colar em uma base redonda
tem como altera o nome no forum
Como detectar se teclado ou controle foi conectado???
erro NO MONOBEHAVIOUR SCRIPTS IN THE FILE
Seleção de Personagem
[ASSET PACKAGE] Game Check Update
Adicionar mais um ataque ao inimigo.
Como faço para Camera ignorar um objeto?
Segundo Teaser do meu novo jogo galera, Sanatório Macabro. Em breve
[RESOLVIDO] VSCode não mostra erros nem identa o Código
Funcionalidades Unity
Baixem meu jogo O Labirinto v1.25 completo e gratuito
Player girando e animação não executa
[RESOLVIDO] Problema com C# e Rigidbody
[RESOLVIDO] Recarregar arma.
Como acessar o Smoothness das texturas do terrain
Sistema de Tiro com Raycast
Velocidade com Button UI.
ERRO AO UPAR NA GOOGLE PLAY STORE
me ajuda por favor
Animaçoes não executa, nem a IDLE
Mini-Map
[TUTORIAL] Como o C# funciona
A Imagem do Objeto não muda
Animaçoes nao executa mais, nem a Idle
[RESOLVIDO] Como usar um Botao(GameObject) igual a um Botao(UI) no Mobile
Sistema de Tiro com Raycast
Algum modelador bom? Compro Modelagem
[RESOLVIDO] Rotação invertida, como resolvo isso??
carregamento de dados entre cenas
Blender bugado ????
AUDIO EM UM DETERMINADO MOMENTO
Dúvida sobre modificação do Event Trigger por scritpt
Carro dá spawn no ar
U2019 - Animações e efeitos após jogador levar hit? por outro jogador?
Não consigo Desabilitar um efeito especifico no pós processamento...
Como Desativar e mudar qualidade de sombra por código???
[TUTORIAL] Primeiro programa "complexo" em C# para iniciantes
Eu estou com dúvida de como instalar a unity com Unity Hub
Pulo "muito Alto"
rotação e aceleração.
Movimentação mobile.
Ativar botão
De Blender pra Unity - Cell Fracture não funciona!
sugestões de otimização?
Carregamento com porcentagem...
[RESOLVIDO] Blender Cell Fracture não aparece no Add-ons - Ajuda!
Movimentação - rotação
Erro Codigo de movimentação.
Cronometro 3,2,1 fica bugado ajuda aee...
[Problema] Ativo o Animator e o boneco não sai do lugar
Morre pausa e aparece botao pra reiniciar mas reinicia o jogo pausado
Script de movimentação e câmera não executa corretamente
FBX não gera sombra
[TUTORIAL] Mostrar Data e Hora atual do Computador em um texto
Sketchup pede para aumentar o projeto
Mudar cor da faixa de texto.
Mexer em variavel de objeto instanciado
Como utilizar o design pattern MVC na Unity?
[RESOLVIDO] RIGIDYBODY tá pulando sozinho pra longe. O que pode ser?
[RESOLVIDO] Compatibilidade e travamentos - unity android
Alguem sabe um meio pra fazer um habitat com criaturas?
[RESOLVIDO] Ajuda com script simples
[RESOLVIDO] Como trocar uma imagem ao clicar num botão em unity c#
[RESOLVIDO] Ponto A ao Ponto B em um determinado tempo
[RESOLVIDO] Duvida Unity (C#)
[RESOLVIDO] Bug no tittle screen
[RESOLVIDO] Erro CS0122
Projeto em desenvolvimento Yoda Runner.
[RESOLVIDO] Duvida Unity (C#)
Duvida com inimigo
Problemas com a colisão do unity
Carros não ficam no chão
Troca de Nivel
[TUTORIAL] Wheel Collider - como configurar corretamente.
Movimentação em SQM Unity 2D
Movimentaçao por SQM / UNITY 2D
[ FIND ME ] Game em Desenvolvimento
Como fazer um sistema de waypoints com espera.
Duvida de como usar varias imagens para cria um obj em 3d
Como usar botao voltar do celular?
Erro no SketchUP
Unity - Ludo usando Grafos, mas sem sucesso
Limite de rotação...
Impedir o toque em uma região da tela
Modelo Singletoon no Unity 2019
steamworks bundle com outros desenvolvedores
[TUTORIAL] Unity 3D - Dependências de compilação
JOGO "CHALLENGE" BETA
[RESOLVIDO] Teclas não funciona
[RESOLVIDO] Incluir a pasta e demais arquivos na finalização do projeto
Unity - Jogo LUDO usando apenas Triggers
Hoje à(s) 11:12 am
Hoje à(s) 10:37 am
Hoje à(s) 1:20 am
Ontem à(s) 1:31 pm
Dom Jul 25, 2021 11:12 pm
Dom Jul 25, 2021 10:51 pm
Dom Jul 25, 2021 6:16 pm
Dom Jul 25, 2021 4:03 pm
Dom Jul 25, 2021 12:39 pm
Sab Jul 24, 2021 11:02 pm
Sab Jul 24, 2021 9:35 pm
Sab Jul 24, 2021 12:11 pm
Sab Jul 24, 2021 3:55 am
Sex Jul 23, 2021 4:02 pm
Sex Jul 23, 2021 2:26 pm
Sex Jul 23, 2021 11:50 am
Qui Jul 22, 2021 8:08 pm
Qui Jul 22, 2021 6:06 pm
Qui Jul 22, 2021 3:38 pm
Qui Jul 22, 2021 3:00 pm
Qui Jul 22, 2021 10:47 am
Qua Jul 21, 2021 6:09 pm
Qua Jul 21, 2021 6:07 pm
Qua Jul 21, 2021 3:41 pm
Qua Jul 21, 2021 5:00 am
Qua Jul 21, 2021 12:30 am
Ter Jul 20, 2021 7:17 pm
Ter Jul 20, 2021 1:21 pm
Ter Jul 20, 2021 10:24 am
Ter Jul 20, 2021 8:27 am
Ter Jul 20, 2021 6:23 am
Ter Jul 20, 2021 6:09 am
Seg Jul 19, 2021 9:06 pm
Seg Jul 19, 2021 9:09 am
Seg Jul 19, 2021 12:22 am
Dom Jul 18, 2021 11:20 pm
Dom Jul 18, 2021 9:10 pm
Dom Jul 18, 2021 2:55 pm
Dom Jul 18, 2021 11:17 am
Sab Jul 17, 2021 11:10 pm
Sab Jul 17, 2021 11:00 pm
Sab Jul 17, 2021 10:49 pm
Sab Jul 17, 2021 10:38 pm
Sab Jul 17, 2021 7:53 pm
Sab Jul 17, 2021 11:20 am
Sab Jul 17, 2021 11:12 am
Sab Jul 17, 2021 6:52 am
Sab Jul 17, 2021 6:39 am
Sab Jul 17, 2021 6:32 am
Sab Jul 17, 2021 6:28 am
Sab Jul 17, 2021 1:16 am
Sex Jul 16, 2021 7:29 pm
Sex Jul 16, 2021 5:40 pm
Sex Jul 16, 2021 5:02 pm
Sex Jul 16, 2021 12:49 pm
Sex Jul 16, 2021 9:25 am
Sex Jul 16, 2021 12:20 am
Qui Jul 15, 2021 6:16 pm
Qui Jul 15, 2021 5:06 pm
Qua Jul 14, 2021 5:59 pm
Qua Jul 14, 2021 5:35 pm
Qua Jul 14, 2021 11:02 am
Seg Jul 12, 2021 9:27 pm
Seg Jul 12, 2021 12:13 pm
Dom Jul 11, 2021 11:08 pm
Dom Jul 11, 2021 10:30 pm
Dom Jul 11, 2021 7:13 pm
Sab Jul 10, 2021 7:05 pm
Sab Jul 10, 2021 10:05 am
Sex Jul 09, 2021 2:51 pm
Qui Jul 08, 2021 7:36 pm
Qui Jul 08, 2021 7:13 pm
Qui Jul 08, 2021 1:53 pm
Qui Jul 08, 2021 1:14 pm
Qui Jul 08, 2021 12:59 pm
Qua Jul 07, 2021 11:48 pm
Qua Jul 07, 2021 10:13 pm
Qua Jul 07, 2021 2:14 pm
Ter Jul 06, 2021 7:51 pm
Ter Jul 06, 2021 1:30 pm
Ter Jul 06, 2021 8:38 am
Seg Jul 05, 2021 1:17 am
Sab Jul 03, 2021 12:36 pm
Sab Jul 03, 2021 2:29 am
Sex Jul 02, 2021 11:12 pm
Sex Jul 02, 2021 1:56 pm
Sex Jul 02, 2021 10:29 am
Qui Jul 01, 2021 12:59 am
Ter Jun 29, 2021 9:30 pm
Ter Jun 29, 2021 1:38 am
Seg Jun 28, 2021 6:55 pm
Seg Jun 28, 2021 6:13 pm
Seg Jun 28, 2021 4:27 pm
Seg Jun 28, 2021 9:39 am
Dom Jun 27, 2021 4:49 pm
Sab Jun 26, 2021 3:49 pm
Sab Jun 26, 2021 12:57 pm
Sab Jun 26, 2021 10:47 am
Sex Jun 25, 2021 8:03 pm
Crash Psycho
stratengine
danilojpbr212
Charlesoff
Pokedlg
kaiquecachoeira1
VitinRuas
Lester202123
bruno92
Fagner
aikow
Pokedlg
FelipeSouza11
ViniciusTKH
Charlesoff
Patrick
WLCS22
Vinicius.Oliveira
jeancvo3
MarcosSchultz
amanda.ilg
LucasBR
jeancvo3
SauloeArthur
PauloFR
JoelMJunior
cleitinhoRasta
jhonih00010
PauloFR
PauloFR
PauloFR
PauloFR
crazylagg
Valério
jhonih00010
jhonih00010
PauloFR
Crash Psycho
edu63
PauloFR
PauloFR
PauloFR
PauloFR
Fagner
PauloFR
Franttyck
PauloFR
PauloFR
PauloFR
PauloFR
WLCS22
Morpheus
jhonih00010
WLCS22
Fagner
NKKF
jhonih00010
MatheusTD
MarcosSchultz
Magnatah
Magnatah
Fagner
Charlesoff
MayLeone
MayLeone
MayLeone
RodrigoPrivilegium
Fagner
ProBrStalker
ronigleydson
a32515
RobsonRAS
VittorTGame23
brunera
patriicia
ffabim
VittorTGame23
jeancvo3
Fagner
Fagner
Pokedlg
Fagner
Shiimo
Valmi
Crash Psycho
Fagner
crazylagg
Fagner
Edivandro2706
WLCS22
Magnatah
acefogo
Fagner
diegopds
MarcosSchultz
lauderson
Esteban
Moura
WLCS22

Camera Height

Ir para baixo

DÚVIDA Camera Height

Mensagem por saccasolutions 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 : 449
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por Fagner 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 : 3059
REPUTAÇÃO : 596
Áreas de atuação : Modelagem 3D, Programação.
Respeito as regras : Camera Height  Aad8pUi

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions 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 : 449
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por Fagner 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 : 3059
REPUTAÇÃO : 596
Áreas de atuação : Modelagem 3D, Programação.
Respeito as regras : Camera Height  Aad8pUi

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por MarcosSchultz 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 : 63613
REPUTAÇÃO : 2582
Idade : 24
Áreas de atuação : Administrador do fórum
Respeito as regras : Camera Height  Aad8pUi

https://www.schultzgames.com

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions 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 : 449
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions 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 : 449
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por saccasolutions 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 : 449
REPUTAÇÃO : 0
Respeito as regras : Camera Height  WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Camera Height

Mensagem por Fagner 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 : 3059
REPUTAÇÃO : 596
Áreas de atuação : Modelagem 3D, Programação.
Respeito as regras : Camera Height  Aad8pUi

Ir para o topo Ir para baixo

Ir para o topo


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