mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-17 18:40:33 +00:00
Benchmark/Tanks example: name players for easier debugging
This commit is contained in:
parent
fdc9369de4
commit
f74d072165
@ -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;
|
||||
|
@ -22,14 +22,25 @@ 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.
|
||||
// (SyncVar hook would only update on clients, not on server)
|
||||
healthBar.text = new string('-', health);
|
||||
|
||||
|
||||
// take input from focused window only
|
||||
if(!Application.isFocused) return;
|
||||
if(!Application.isFocused) return;
|
||||
|
||||
// movement for local player
|
||||
if (isLocalPlayer)
|
||||
|
Loading…
Reference in New Issue
Block a user