mirror of
https://github.com/Kaveinator/NetickProForUnity.git
synced 2025-10-26 09:49:06 -07:00
Moved PlayerSpawner to Netick.Samples namespace.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,9 @@ using Network = Netick.Unity.Network;
|
||||
|
||||
namespace Netick.Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a helper script for quick prototyping, used to start Netick.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Netick/Game Starter")]
|
||||
public class GameStarter : NetworkEventsListener
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@ using Network = Netick.Unity.Network;
|
||||
|
||||
namespace Netick.Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a helper script for quick prototyping, used to show useful network information of Netick.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Netick/Network Info")]
|
||||
public class NetworkInfo : NetworkEventsListener
|
||||
{
|
||||
|
||||
@@ -1,37 +1,41 @@
|
||||
using UnityEngine;
|
||||
using Netick;
|
||||
using Netick.Unity;
|
||||
using UnityEngine;
|
||||
using Network = Netick.Unity.Network;
|
||||
|
||||
/// <summary>
|
||||
/// This is a helper script for quick prototyping, used to spawn/despawn a player prefab when a player (client or host) has connected/disconnected.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Netick/Player Spawner")]
|
||||
public class PlayerSpawner : NetworkEventsListener
|
||||
namespace Netick.Samples
|
||||
{
|
||||
public GameObject PlayerPrefab;
|
||||
public Transform SpawnPosition;
|
||||
public float HorizontalOffset = 5f;
|
||||
public bool StaggerSpawns = true;
|
||||
public bool DestroyPlayerObjectWhenLeaving = true;
|
||||
|
||||
// This is called on the server when a player has connected.
|
||||
public override void OnPlayerConnected(NetworkSandbox sandbox, Netick.NetworkPlayer client)
|
||||
/// <summary>
|
||||
/// This is a helper script for quick prototyping, used to spawn/despawn a player prefab when a player (client or host) has connected/disconnected.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Netick/Player Spawner")]
|
||||
public class PlayerSpawner : NetworkEventsListener
|
||||
{
|
||||
var spawnPos = SpawnPosition.position;
|
||||
if (StaggerSpawns)
|
||||
spawnPos += (HorizontalOffset * Vector3.left) * (1 + sandbox.ConnectedPlayers.Count);
|
||||
var player = sandbox.NetworkInstantiate(PlayerPrefab, spawnPos, SpawnPosition.rotation, client);
|
||||
client.PlayerObject = player;
|
||||
}
|
||||
public GameObject PlayerPrefab;
|
||||
public Transform SpawnPosition;
|
||||
public float HorizontalOffset = 5f;
|
||||
public bool StaggerSpawns = true;
|
||||
public bool DestroyPlayerObjectWhenLeaving = true;
|
||||
|
||||
// This is called on the server when a player has disconnected.
|
||||
public override void OnPlayerDisconnected(NetworkSandbox sandbox, Netick.NetworkPlayer client, TransportDisconnectReason transportDisconnectReason)
|
||||
{
|
||||
if (!DestroyPlayerObjectWhenLeaving)
|
||||
return;
|
||||
// This is called on the server when a player has connected.
|
||||
public override void OnPlayerConnected(NetworkSandbox sandbox, Netick.NetworkPlayer client)
|
||||
{
|
||||
var spawnPos = SpawnPosition.position;
|
||||
if (StaggerSpawns)
|
||||
spawnPos += (HorizontalOffset * Vector3.left) * (1 + sandbox.ConnectedPlayers.Count);
|
||||
var player = sandbox.NetworkInstantiate(PlayerPrefab, spawnPos, SpawnPosition.rotation, client);
|
||||
client.PlayerObject = player;
|
||||
}
|
||||
|
||||
var netObj = client.PlayerObject as NetworkObject;
|
||||
if (netObj != null)
|
||||
Sandbox.Destroy(netObj);
|
||||
// This is called on the server when a player has disconnected.
|
||||
public override void OnPlayerDisconnected(NetworkSandbox sandbox, Netick.NetworkPlayer client, TransportDisconnectReason transportDisconnectReason)
|
||||
{
|
||||
if (!DestroyPlayerObjectWhenLeaving)
|
||||
return;
|
||||
|
||||
var netObj = client.PlayerObject as NetworkObject;
|
||||
if (netObj != null)
|
||||
Sandbox.Destroy(netObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.karrar.netick",
|
||||
"version": "0.13.18",
|
||||
"version": "0.13.19",
|
||||
"displayName": "Netick",
|
||||
"description": "A networking solution for Unity",
|
||||
"unity": "2021.3",
|
||||
|
||||
Reference in New Issue
Block a user