Skip to content

Commit

Permalink
fix: fixing pong example
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Aug 17, 2021
1 parent 2ca4f5b commit 5ccb42e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Assets/Mirage/Samples~/Pong/Scripts/PaddleSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ public class PaddleSpawner : CharacterSpawner

GameObject ball;

public override void Awake()
{
base.Awake();

if (Server != null)
{
Server.Disconnected.AddListener(OnServerAddPlayer);
}
}

public override void OnServerAddPlayer(INetworkPlayer player)
{
// add player at correct spawn position
Expand All @@ -25,10 +35,9 @@ public override void OnServerAddPlayer(INetworkPlayer player)
}
}


public void OnServerDisconnect(INetworkPlayer player)
public void OnServerDisconnect(INetworkPlayer _)
{
// destroy ball
// after 1 player disconnects then destroy the balll
if (ball != null)
ServerObjectManager.Destroy(ball);
}
Expand Down

0 comments on commit 5ccb42e

Please sign in to comment.