-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_Ranking.cs
36 lines (33 loc) · 1.04 KB
/
Test_Ranking.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mantega;
using TMPro;
public class Test_Ranking : MonoBehaviour
{
[Header("Movement Statistics")]
[SerializeField] private PlayerMovement playerMovement;
[SerializeField] private Rigidbody playerRb;
public TMP_Text text_playerSpeed;
public float speedRecord;
void Start()
{
if(playerMovement == null)
Generics.ReallyTryGetComponent(gameObject, out playerMovement);
playerRb = playerMovement.GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float playerSpeed = new Vector2(playerRb.velocity.x, playerRb.velocity.z).magnitude;
if(playerSpeed > speedRecord)
speedRecord = playerSpeed;
SetMovementStatistics(playerSpeed);
}
public void SetMovementStatistics(float currentSpeed)
{
if (text_playerSpeed == null)
return;
text_playerSpeed.text = $"Velocity: {currentSpeed}\nRecord: {speedRecord}";
}
}