From 783946a48c39f92f7bedf715803dd4dbe8383632 Mon Sep 17 00:00:00 2001 From: nexovec <30555041+nexovec@users.noreply.github.com> Date: Sun, 30 Jan 2022 12:48:10 +0100 Subject: [PATCH] fixed initial player rotation --- Assets/Materials/red glow.mat | 8 +++++--- Assets/Scenes/Vasek.unity | 2 +- Assets/Scripts/PlayerController.cs | 20 ++++++++++++++------ Assets/Scripts/UiController.cs | 5 ++++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Assets/Materials/red glow.mat b/Assets/Materials/red glow.mat index 8c1a638..840e236 100644 --- a/Assets/Materials/red glow.mat +++ b/Assets/Materials/red glow.mat @@ -55,13 +55,14 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + m_Ints: [] m_Floats: - _BumpScale: 1 - _Cutoff: 0.5 - _DetailNormalMapScale: 1 - _DstBlend: 0 - _GlossMapScale: 1 - - _Glossiness: 0.5 + - _Glossiness: 0.666 - _GlossyReflections: 1 - _Metallic: 0 - _Mode: 0 @@ -73,5 +74,6 @@ Material: - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 5.0387836, g: 0, b: 0, a: 1} + - _Color: {r: 0.3679245, g: 0.3679245, b: 0.3679245, a: 1} + - _EmissionColor: {r: 4.3155437, g: 0.14249445, b: 0.14249445, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Scenes/Vasek.unity b/Assets/Scenes/Vasek.unity index 6c288bf..1f8b54d 100644 --- a/Assets/Scenes/Vasek.unity +++ b/Assets/Scenes/Vasek.unity @@ -5291,7 +5291,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1942086892, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[3].m_MethodName - value: OnStartGameBtnClick + value: OnNewGameBtnClick objectReference: {fileID: 0} - target: {fileID: 1942086892, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[3].m_TargetAssemblyTypeName diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index cf2c69a..a6161ab 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -63,6 +63,7 @@ public class PlayerController : MonoBehaviour // Update is called once per frame void Update() { + if (UiController.isInMenu) return; rotationX += -Input.GetAxis("Mouse Y") * lookSpeed; rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit); playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0); @@ -107,21 +108,28 @@ public class PlayerController : MonoBehaviour isGrounded = false; } - if (audioSource != null && audioClips.Count > 0) { + if (audioSource != null && audioClips.Count > 0) + { if ((currentSpeed + speedModifier) > speed * 3f && (currentSpeed + speedModifier) < speed * 6f) { - if (audioClips.Count > 1 && audioSource.clip != audioClips[1]) { + if (audioClips.Count > 1 && audioSource.clip != audioClips[1]) + { audioSource.Stop(); audioSource.clip = audioClips[1]; audioSource.Play(); } - } else if ((currentSpeed + speedModifier) <= speed * 3f) { - if (audioSource.clip != audioClips[0]) { + } + else if ((currentSpeed + speedModifier) <= speed * 3f) + { + if (audioSource.clip != audioClips[0]) + { audioSource.Stop(); audioSource.clip = audioClips[0]; audioSource.Play(); } - } else if ((currentSpeed + speedModifier) >= speed * 6f) { + } + else if ((currentSpeed + speedModifier) >= speed * 6f) + { if (audioClips.Count > 2 && audioSource.clip != audioClips[2]) { audioSource.Stop(); @@ -147,7 +155,7 @@ public class PlayerController : MonoBehaviour inAir = false; } - if (Vector3.Distance(transform.position, new Vector3(0f,0f, transform.position.z)) > 10f) + if (Vector3.Distance(transform.position, new Vector3(0f, 0f, transform.position.z)) > 10f) { // Debug.Log("Player is falling :)"); this.isFalling = true; diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index e94ac30..c49e504 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -13,6 +13,8 @@ public class UiController : MonoBehaviour public GameObject menuCamera; public GameObject playerCamera; + public static bool isInMenu = true; + public static float distance = 0; public static int highScore = 0; private float oldDistance = 0.0f; @@ -26,8 +28,9 @@ public class UiController : MonoBehaviour UiController.LoadGame(); } - public void OnStartGameBtnClick() + public void OnNewGameBtnClick() { + UiController.isInMenu = false; menuCamera.SetActive(false); playerCamera.SetActive(true); }