diff --git a/Assets/MinimapStatrScript.cs b/Assets/MinimapStatrScript.cs index 640fd077..9827b72c 100644 --- a/Assets/MinimapStatrScript.cs +++ b/Assets/MinimapStatrScript.cs @@ -7,9 +7,12 @@ public class MinimapStatrScript : MonoBehaviour [SerializeField] private SelectCarGameScript _SelectCarGameScript; - private void Start() + public void Starter() { - _followTarget.target = _SelectCarGameScript._CurrentCar.transform; - _followYRotation.target = _SelectCarGameScript._CurrentCar.transform; + if (_SelectCarGameScript._CurrentCar != null) + { + _followTarget.target = _SelectCarGameScript._CurrentCar.transform; + _followYRotation.target = _SelectCarGameScript._CurrentCar.transform; + } } } diff --git a/Assets/Racing_Game/Data/Scripts/Map/FollowTarget.cs b/Assets/Racing_Game/Data/Scripts/Map/FollowTarget.cs index a736f612..7ac0c7ae 100644 --- a/Assets/Racing_Game/Data/Scripts/Map/FollowTarget.cs +++ b/Assets/Racing_Game/Data/Scripts/Map/FollowTarget.cs @@ -10,6 +10,6 @@ public class FollowTarget : MonoBehaviour // Update is called once per frame void Update() { - transform.position = target.transform.position + offset; + if(target != null) transform.position = target.transform.position + offset; } } diff --git a/Assets/Racing_Game/Data/Scripts/Map/FollowYRotation.cs b/Assets/Racing_Game/Data/Scripts/Map/FollowYRotation.cs index 384e8f28..eb88a8b8 100644 --- a/Assets/Racing_Game/Data/Scripts/Map/FollowYRotation.cs +++ b/Assets/Racing_Game/Data/Scripts/Map/FollowYRotation.cs @@ -8,6 +8,6 @@ public class FollowYRotation : MonoBehaviour void Update() { - transform.eulerAngles = new Vector3(0 ,target.eulerAngles.y, 0); + if (target != null) transform.eulerAngles = new Vector3(0 ,target.eulerAngles.y, 0); } } diff --git a/Assets/Racing_Game/Data/Scripts/Start/Starter.cs b/Assets/Racing_Game/Data/Scripts/Start/Starter.cs index fcdbb222..da74538c 100644 --- a/Assets/Racing_Game/Data/Scripts/Start/Starter.cs +++ b/Assets/Racing_Game/Data/Scripts/Start/Starter.cs @@ -13,7 +13,7 @@ public class Starter : MonoBehaviour [SerializeField] private Image _borders; - + [SerializeField] private MinimapStatrScript[] _MinimapStatrScript; private void Start() { @@ -63,6 +63,19 @@ public class Starter : MonoBehaviour DontMovePlayer[1].DeactivateInput(); } + if (_MinimapStatrScript.Length != 0) + { + if (_MinimapStatrScript.Length == 1) + { + _MinimapStatrScript[0].Starter(); + } + else if (_MinimapStatrScript.Length == 2) + { + _MinimapStatrScript[0].Starter(); + _MinimapStatrScript[1].Starter(); + } + } + _borders.enabled = true; } diff --git a/Assets/Racing_Game/Data/Scripts/UI/DriftScore.cs b/Assets/Racing_Game/Data/Scripts/UI/DriftScore.cs index fbaf1c36..a35e6afa 100644 --- a/Assets/Racing_Game/Data/Scripts/UI/DriftScore.cs +++ b/Assets/Racing_Game/Data/Scripts/UI/DriftScore.cs @@ -30,7 +30,7 @@ public class DriftScore : MonoBehaviour private IEnumerator stopDriftingCoroutine = null; - private void Start() + public void Starter() { driftingObject.SetActive(false); } diff --git a/Assets/Racing_Game/Scence/Maps/1Map/FirstMap.unity b/Assets/Racing_Game/Scence/Maps/1Map/FirstMap.unity index c9fe57a4..02efdee9 100644 Binary files a/Assets/Racing_Game/Scence/Maps/1Map/FirstMap.unity and b/Assets/Racing_Game/Scence/Maps/1Map/FirstMap.unity differ diff --git a/Assets/Racing_Game/UI/MainUI/Scripts/TimerOnInactiveScript.cs b/Assets/Racing_Game/UI/MainUI/Scripts/TimerOnInactiveScript.cs index 0c002b97..ef3a187d 100644 --- a/Assets/Racing_Game/UI/MainUI/Scripts/TimerOnInactiveScript.cs +++ b/Assets/Racing_Game/UI/MainUI/Scripts/TimerOnInactiveScript.cs @@ -46,15 +46,19 @@ public class TimerOnInactiveScript : MonoBehaviour { ResetTimer(); MoveCameraFromRound(); + //Debug.Log("gamepad"); } if (control is AxisControl axis) { float value = axis.ReadValue(); + + if (value != 0) { ResetTimer(); MoveCameraFromRound(); } + //Debug.Log($"gamepad {value}"); } } } @@ -64,7 +68,9 @@ public class TimerOnInactiveScript : MonoBehaviour { ResetTimer(); MoveCameraFromRound(); - } } + //Debug.Log("keyboard"); + } + } //-------------------------------------------------------------------------------------------- diff --git a/Assets/SelectCarGameScript.cs b/Assets/SelectCarGameScript.cs index aaaf3551..5239a731 100644 --- a/Assets/SelectCarGameScript.cs +++ b/Assets/SelectCarGameScript.cs @@ -23,6 +23,12 @@ public class SelectCarGameScript : MonoBehaviour [SerializeField] private RCC_UIDashboardDisplay _RCC_UIDashboardDisplay; + //[SerializeField] private FollowTarget _FollowTarget; + + //[SerializeField] private FollowYRotation _FollowYRotation; + + + private void Start() { _Player -= 1; @@ -39,7 +45,9 @@ public class SelectCarGameScript : MonoBehaviour _CinemachineVC.Follow = _CurrentCar.transform; _CinemachineVC.LookAt = _CurrentCar.transform; + _DriftScore.playerRB = _CurrentCar.GetComponent(); + _DriftScore.Starter(); //Debug.Log("Дрифт указан"); _CurrentCar.SetActive(true); @@ -53,6 +61,11 @@ public class SelectCarGameScript : MonoBehaviour _RCC_UIDashboardDisplay.vehicle = _CurrentCar.GetComponent(); //Debug.Log("Контроллеры управления указаны"); + //if (_FollowTarget != null) + //{ + // _FollowTarget.target = _CurrentCar.transform; + // _FollowYRotation.target = _CurrentCar.transform; + //} } //private void Start()