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:
Dúvida de pegar variável de outro script / sistema de compra e venda (Ajuda aí pfv)
sistema de dinheiro
Meu personagem pula mesmo quando ja está no ar pulando
[TUTORIAL] AI Enemy ( Jogos de terror )
Meu personagem consegue pular infinitamente
[DIVULGAÇÃO] CORRAM !! CURSO DE 500 REAIS COM 93% DE DESCONTO!!
Precisando de ajuda em um script
Forme Mais Palavras (disponível na Play Store)
Qual a diferença??
Baixar asset bundle no dispositivo
Limit jogo de corrida
A Grande Evolução dos Jogos Indie!
[TUTORIAL] Unity + PHP + Mysql (com PDO)
[TUTORIAL] Correção para múltiplos audio Listeners
Existe outras formas de multiplayer sem ser pelo Photon ou Unet?
Level Designer
ALGUÉM INTERESSADO EM DESENVOLVER UM KIT THIRD PERSON?
Duvida sobre banco de dados online
[TUTORIAL] Card Game Super Simples Mythomania
EFEITO EM VIDRO
Ola sou programador e preciso da sua ajuda!!
Precisa de Animador , Modelador e Concept Art
ATIVAR E DESATIVAR EMISSION COM MOUSE CLICK
AD-MOB ERRO >>>> AJUDA
Terreno sumindo
[____TÓPICO LIVRE____] FALE O QUE QUISER (Parte 2)
Botão de Pause muda de lugar após build do jogo
Erro System.Delegate.CreateDelegate ao fazer um botão de Pause para o jogo
Como carregar multiplas cenas de uma vez?
[TUTORIAL] MENU PRINCIPAL - UNITY 5 (5.3 ou superior) (Com UI)
Duvida...
[MAKING-OF] Bastidores da criação do jogo The Hero of Krintau!
Alguém conhece algum tutorial para criar um jogo parecido com esse na Unity?
Duvida em customização de carro na unity
Tutorial Como Fazer Uma Chama de Vela Com Movimento Natural Unity
[Jogo em andamento] The Legends of Koai
Alguém pode ajuda a fazer sistema de destruir e construir?
[ASSET] Modelo 3d guitarra gibson firebird "low poly" e outros...
como fazer um sistema de captura igual de pokemon generations
Como posso chamar o Cursor do Mouse no script?
[TUTORIAL] Inventario com ScritableObject parte 2
Galera como posso fazer um sistema de combo no mobile ?
duvida
COMO EU POSSO FAZER MEU PERSONAGEM FICAR AGACHADO ENQUANTO EU APERTO O BOTÃO
[PROBLEMA] First Person Controller script não reproduz sons de passo
[TUTORIAL] Sistema COMPLETO de câmeras
Problema em causar dano no player
Como simular um segundo controle no Unity?
Alguém pode me ajuda a coloca animação quando anda?
Erro Movimentação RPG
Unity ML-Agents
PLANECAOS Offline Tiro FPS - Android
Dúvida sobre implementação de sistema de criar/editar mapa unity/unreal
[____ASSET____] MS Vehicle System (FREE VERSION)
Onde foi parar Input Debugger no Unity?
Referência nula em script da Unity
[JOGO MOBILE] The Hero of Krintau (Gratuito na Play Store!)
Verificar se a versao do jogo é igual a da Play Store
sistema de motocicleta
Como posso criar um sistema de atacar?
Player se movimenta em direção diferente da posição da camera
PlayerPrefs salva SetActive??
Documentações, Livros e Tutoriais gratuitos... Extensa gama de recursos
TEXTURIZAÇÃO DE CENARIO GRANDE | TECNICA
Girar arma junto com personagem para ele so atacar pela frente !
Erro Unity 2019.3.14f1
[PESQUISA] Pra que plataforma você prefere esse estilo de jogo?
Água no unity 2019.3
COMO SALVAR O PLAYER QUANDO ELE TIVER DESATIVO OU ATIVADO??
Como adiciono um SOM neste script de pulo?
[TUTORIAL] Animação customizável (Por scripts)
Como posso criar um sistema de direção para meus ataques.
pulo com botao UI
Não Consigo Fazer Alterações Em Transform/Sprite Renderer Quando Em Exexução
Como definir limites de zoom para um objeto inspecionado?
[____COLABORE COM O FÓRUM____] Doação para a renovação do domínio
Proposta de Parceria em Belo Horizonte
2 Objetos no mesmo spawner ao mesmo tempo
Pausar o cronômetro
Problemas com fisica
Trailer do jogo Project Lazarus
Unity 2018.2.17 - PlayMode não funciona animações
Força a um objeto numa lista
problemas com celulares android grande
Variável estática que pode ser consultada por todos - Unity Photon
Como fazer a pontuação aparecer no menu?
Melhorar o desempenho do URP no Android
Banco Thief (Assaltador de Banco)-Android-
Como faço para que meu personagem ao subir em um lugar bem íngreme ele escorregue?
Como posso deixar o fogo da vela mais realista?
COMO FAZER COLISÃO COM CAIXAS TIPO OS PUZZLES DO PATETA E MAX DO SNES?
URP Unity em Android
Nano - Jogo de Estratégia para Android
[TUTORIAL] Teleporte de camera em sequencia com tempo (cutscene)
Movimentaçao por SQM / UNITY 2D
Como Modelar O Corcovado Rio De Janeiro No sketchup Game De Mundo Aberto Artigo 157
Como posso substituir um arquivo já feito?
onde eu encontro o wrap Mode da animação? pfv,preciso parar de dar loop
Limite Máximo de tamanho de mapa na Unity?
Hoje à(s) 7:01 pm
Hoje à(s) 6:59 pm
Hoje à(s) 5:06 pm
Hoje à(s) 3:31 pm
Hoje à(s) 3:09 pm
Hoje à(s) 2:09 pm
Hoje à(s) 11:20 am
Ontem à(s) 3:47 pm
Ontem à(s) 3:35 pm
Ontem à(s) 9:45 am
Ontem à(s) 1:45 am
Qua Jun 03, 2020 10:35 pm
Qua Jun 03, 2020 9:50 pm
Qua Jun 03, 2020 4:21 pm
Qua Jun 03, 2020 3:59 pm
Qua Jun 03, 2020 3:01 pm
Qua Jun 03, 2020 1:26 pm
Qua Jun 03, 2020 8:35 am
Ter Jun 02, 2020 10:05 pm
Ter Jun 02, 2020 9:57 pm
Ter Jun 02, 2020 6:20 pm
Ter Jun 02, 2020 4:48 pm
Seg Jun 01, 2020 11:57 pm
Seg Jun 01, 2020 7:15 pm
Seg Jun 01, 2020 5:22 pm
Seg Jun 01, 2020 2:43 pm
Seg Jun 01, 2020 2:09 pm
Seg Jun 01, 2020 1:37 pm
Seg Jun 01, 2020 1:16 am
Dom Maio 31, 2020 9:19 pm
Dom Maio 31, 2020 1:08 pm
Sab Maio 30, 2020 11:51 pm
Sab Maio 30, 2020 11:43 pm
Sab Maio 30, 2020 5:45 pm
Sab Maio 30, 2020 5:14 pm
Sab Maio 30, 2020 5:10 pm
Sab Maio 30, 2020 4:22 pm
Sab Maio 30, 2020 1:26 pm
Sab Maio 30, 2020 12:09 am
Sex Maio 29, 2020 5:45 pm
Sex Maio 29, 2020 4:18 pm
Sex Maio 29, 2020 2:37 pm
Sex Maio 29, 2020 11:33 am
Sex Maio 29, 2020 11:05 am
Qui Maio 28, 2020 9:29 pm
Qui Maio 28, 2020 9:05 pm
Qui Maio 28, 2020 6:49 pm
Qui Maio 28, 2020 6:01 pm
Qui Maio 28, 2020 5:21 pm
Qui Maio 28, 2020 4:44 pm
Qui Maio 28, 2020 2:36 pm
Qui Maio 28, 2020 5:02 am
Qua Maio 27, 2020 11:59 pm
Qua Maio 27, 2020 10:42 pm
Qua Maio 27, 2020 9:59 pm
Qua Maio 27, 2020 8:52 pm
Qua Maio 27, 2020 7:02 pm
Qua Maio 27, 2020 6:52 pm
Qua Maio 27, 2020 5:13 pm
Qua Maio 27, 2020 5:12 pm
Qua Maio 27, 2020 4:34 pm
Qua Maio 27, 2020 4:04 pm
Qua Maio 27, 2020 10:44 am
Ter Maio 26, 2020 10:22 pm
Ter Maio 26, 2020 5:56 pm
Ter Maio 26, 2020 5:28 pm
Ter Maio 26, 2020 5:21 pm
Ter Maio 26, 2020 5:16 pm
Ter Maio 26, 2020 4:44 pm
Ter Maio 26, 2020 2:06 pm
Seg Maio 25, 2020 11:39 pm
Seg Maio 25, 2020 7:31 pm
Seg Maio 25, 2020 2:04 pm
Seg Maio 25, 2020 12:58 pm
Seg Maio 25, 2020 11:02 am
Dom Maio 24, 2020 8:21 pm
Dom Maio 24, 2020 7:13 pm
Dom Maio 24, 2020 7:05 pm
Dom Maio 24, 2020 5:03 pm
Dom Maio 24, 2020 9:04 am
Sab Maio 23, 2020 4:45 pm
Sab Maio 23, 2020 2:04 pm
Sab Maio 23, 2020 11:40 am
Sab Maio 23, 2020 9:37 am
Sex Maio 22, 2020 8:33 pm
Sex Maio 22, 2020 2:32 pm
Sex Maio 22, 2020 3:46 am
Qui Maio 21, 2020 5:38 pm
Qui Maio 21, 2020 4:52 pm
Qui Maio 21, 2020 3:32 pm
Qui Maio 21, 2020 9:42 am
Qui Maio 21, 2020 2:40 am
Qui Maio 21, 2020 12:41 am
Qua Maio 20, 2020 5:52 pm
Qua Maio 20, 2020 5:05 pm
Qua Maio 20, 2020 2:42 pm
Qua Maio 20, 2020 2:12 pm
Qua Maio 20, 2020 1:05 pm
Ter Maio 19, 2020 7:04 pm
Cristyan
Cristyan
speedluk
Weslley
Weslley
MarcosSchultz
vini024
Weslley
Weslley
numb123
edugamer69
JohnRambo
FabioDev
AnderGames
Weslley
Eris
Diego Felix
gtcmcsgo
Callyde Jr
diegopds
JuniorMoraes
Chilinger
luiza guinho
iToddy
Madness
MarcosSchultz
yashima007
yashima007
Fagner
MarcosSchultz
PauloFR
JohnRambo
AmazingDeliciano
HomemDoAcre
IzraeuEbW
PauloFR
streamer
PauloFR
Callyde Jr
glauco
hendrick22
mateusoss
Spuk
JohnRambo
AmazingDeliciano
adolfomello1
mecjo
lesgoy
streamer
Faker
Emerson Rebouças
Daniel Dória
SabrinaSantos
Edu4rdogx
FelipeSouza11
AnaSenpai
JohnRambo
gtcmcsgo
Yuri Heinz
verme1311
francisco barroso
Kayke_27
Antônio T
MAZUI ESTUDIO
Portela
RafaelSquid1
RafaelSquid1
RafaelSquid1
Kayke_27
Th2y
cyaiber pank
IssacDB
gaspargnc
DougSoares
Weslley
MarcosSchultz
toatoa
AmazingDeliciano
Th2y
Valakinhas
Patrick
Samuelostgamer
maxwarnava
Valakinhas
juansup
Th2y
lesgoy
JohnRambo
Yuri Heinz
Yuri Heinz
RodrigoPrivilegium
lesgoy
lesgoy
gui78h3
Eskeleto
Yuri Heinz
PM JOGOS
gabriel alves souza
vini024

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 : 32
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 : 2051
REPUTAÇÃO : 358
Á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 : 32
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 : 2051
REPUTAÇÃO : 358
Á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 : 62811
REPUTAÇÃO : 2443
Idade : 23
Á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 : 32
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 : 32
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 : 32
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 : 2051
REPUTAÇÃO : 358
Á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