Improved Timer QOL

Made it start on the player first moving and show on the game HUD.
This commit is contained in:
Pasha Bibko
2025-04-29 21:05:23 +01:00
parent f4d15f33e7
commit b86c9f7a14
4 changed files with 108 additions and 4 deletions

View File

@@ -276,7 +276,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -79}
m_AnchoredPosition: {x: 0, y: -200}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4719150856852200805
@@ -353,6 +353,7 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3955103952048326661}
- {fileID: 8335740897561854244}
- {fileID: 6793247590988510300}
- {fileID: 6414998190209660209}
- {fileID: 2457658704519817442}
@@ -502,3 +503,82 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &8883880397071342217
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8335740897561854244}
- component: {fileID: 3941313279583122886}
- component: {fileID: 4448638729554205736}
m_Layer: 5
m_Name: Speed (3)
m_TagString: NoTag
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8335740897561854244
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8883880397071342217}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5671584535948009389}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -250}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3941313279583122886
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8883880397071342217}
m_CullTransparentMesh: 1
--- !u!114 &4448638729554205736
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8883880397071342217}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: New Text

View File

@@ -608,6 +608,17 @@ Transform:
m_CorrespondingSourceObject: {fileID: 1632877289128239282, guid: 403eb740238e6b64690125507aa8e849, type: 3}
m_PrefabInstance: {fileID: 1957750500}
m_PrefabAsset: {fileID: 0}
--- !u!114 &259691000 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 4448638729554205736, guid: 04e3e796397021e4a8006d7d49ba6083, type: 3}
m_PrefabInstance: {fileID: 1080427054}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &314221797
GameObject:
m_ObjectHideFlags: 0
@@ -25499,6 +25510,10 @@ PrefabInstance:
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 8262238277154956783, guid: 403eb740238e6b64690125507aa8e849, type: 3}
propertyPath: m_TimeText
value:
objectReference: {fileID: 259691000}
- target: {fileID: 8262238277154956783, guid: 403eb740238e6b64690125507aa8e849, type: 3}
propertyPath: m_DeadCanvas
value:

View File

@@ -36,6 +36,16 @@ public partial class PlayerMovement : MonoBehaviour
// Calculates the movement direction
m_MoveDir = (m_Orientation.forward * m_Input.y) + (m_Orientation.right * m_Input.x);
if (m_MoveDir != Vector3.zero && m_StartTime == 0.0f)
{
m_StartTime = Time.time;
}
if (m_StartTime != 0.0f)
{
m_TimeText.text = (Time.time - m_StartTime).ToString("0.00") + " s";
}
//
if (m_OnSlope)
{

View File

@@ -46,6 +46,7 @@ public partial class PlayerMovement : MonoBehaviour
[SerializeField] Canvas m_DeadCanvas;
[SerializeField] Canvas m_CompletedCanvas;
[SerializeField] Text m_CompletedText;
[SerializeField] Text m_TimeText;
[Header("Debug Settings")]
[SerializeField] Text m_SpeedDisplay;
@@ -93,7 +94,7 @@ public partial class PlayerMovement : MonoBehaviour
bool m_IsDead = false;
float m_StartTime;
float m_StartTime = 0.0f;
// Only instance of the player
static PlayerMovement s_Instance;
@@ -108,8 +109,6 @@ public partial class PlayerMovement : MonoBehaviour
// Start is called before the first frame update
private void Start()
{
m_StartTime = Time.time;
//
m_CompletedCanvas.enabled = false;
m_DeadCanvas.enabled = false;