Benchmark/Tanks example: name players for easier debugging

This commit is contained in:
mischa 2024-10-18 14:18:30 +02:00
parent fdc9369de4
commit f74d072165
2 changed files with 24 additions and 2 deletions

View File

@ -6,6 +6,17 @@ public class PlayerMovement : NetworkBehaviour
{
public float speed = 5;
// naming for easier debugging
public override void OnStartClient()
{
name = $"Player[{netId}|{(isLocalPlayer ? "local" : "remote")}]";
}
public override void OnStartServer()
{
name = $"Player[{netId}|server]";
}
void Update()
{
if (!isLocalPlayer) return;

View File

@ -22,6 +22,17 @@ public class Tank : NetworkBehaviour
[Header("Stats")]
[SyncVar] public int health = 5;
// naming for easier debugging
public override void OnStartClient()
{
name = $"Player[{netId}|{(isLocalPlayer ? "local" : "remote")}]";
}
public override void OnStartServer()
{
name = $"Player[{netId}|server]";
}
void Update()
{
// always update health bar.