This commit is contained in:
MrGadget1024 2023-02-14 06:52:58 -05:00
parent 31349c708c
commit b53892e2de
4 changed files with 41 additions and 23 deletions

View File

@ -1530,13 +1530,14 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 821201137} - component: {fileID: 821201137}
- component: {fileID: 821201136}
- component: {fileID: 821201135} - component: {fileID: 821201135}
- component: {fileID: 821201138}
- component: {fileID: 821201142} - component: {fileID: 821201142}
- component: {fileID: 821201138}
- component: {fileID: 821201136}
- component: {fileID: 821201140} - component: {fileID: 821201140}
- component: {fileID: 821201139} - component: {fileID: 821201139}
- component: {fileID: 821201141} - component: {fileID: 821201141}
- component: {fileID: 821201143}
m_Layer: 0 m_Layer: 0
m_Name: NetworkManager m_Name: NetworkManager
m_TagString: Untagged m_TagString: Untagged
@ -1570,10 +1571,10 @@ MonoBehaviour:
playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3} playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3}
autoCreatePlayer: 1 autoCreatePlayer: 1
playerSpawnMethod: 0 playerSpawnMethod: 0
spawnPrefabs: spawnPrefabs: []
- {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3}
- {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3}
timeInterpolationGui: 1 timeInterpolationGui: 1
botPrefab: {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3}
npcPrefab: {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3}
--- !u!114 &821201136 --- !u!114 &821201136
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1708,6 +1709,18 @@ MonoBehaviour:
debugLog: 0 debugLog: 0
statisticsGUI: 0 statisticsGUI: 0
statisticsLog: 0 statisticsLog: 0
--- !u!114 &821201143
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 821201133}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc5b42cbfc38b1c4d86fd25905b19e29, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &920376379 --- !u!1 &920376379
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1530,10 +1530,10 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 821201137} - component: {fileID: 821201137}
- component: {fileID: 821201136}
- component: {fileID: 821201135} - component: {fileID: 821201135}
- component: {fileID: 821201138}
- component: {fileID: 821201134} - component: {fileID: 821201134}
- component: {fileID: 821201138}
- component: {fileID: 821201136}
- component: {fileID: 821201140} - component: {fileID: 821201140}
- component: {fileID: 821201139} - component: {fileID: 821201139}
- component: {fileID: 821201141} - component: {fileID: 821201141}
@ -1557,7 +1557,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0110f245bfcfc7d459681f7bd9ebc590, type: 3} m_Script: {fileID: 11500000, guid: 0110f245bfcfc7d459681f7bd9ebc590, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
port: 7777 port: 27777
maxMessageSize: 16384 maxMessageSize: 16384
handshakeMaxSize: 3000 handshakeMaxSize: 3000
noDelay: 1 noDelay: 1
@ -1586,8 +1586,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
dontDestroyOnLoad: 1 dontDestroyOnLoad: 1
runInBackground: 1 runInBackground: 1
autoStartServerBuild: 1 autoStartServerBuild: 0
autoConnectClientBuild: 0 autoConnectClientBuild: 1
sendRate: 30 sendRate: 30
offlineScene: Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity offlineScene: Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity
onlineScene: Assets/Mirror/Examples/TestNT/Scenes/Online.unity onlineScene: Assets/Mirror/Examples/TestNT/Scenes/Online.unity
@ -1598,10 +1598,10 @@ MonoBehaviour:
playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3} playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3}
autoCreatePlayer: 1 autoCreatePlayer: 1
playerSpawnMethod: 0 playerSpawnMethod: 0
spawnPrefabs: spawnPrefabs: []
- {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3}
- {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3}
timeInterpolationGui: 1 timeInterpolationGui: 1
botPrefab: {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3}
npcPrefab: {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3}
--- !u!114 &821201136 --- !u!114 &821201136
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -36,7 +36,7 @@ void Update()
void CmdSpawnNPC() void CmdSpawnNPC()
{ {
//Vector3 spawnPos = transform.position + Vector3.forward; //Vector3 spawnPos = transform.position + Vector3.forward;
GameObject npc = Instantiate(NetworkManager.singleton.spawnPrefabs[0]); GameObject npc = Instantiate(TestNTNetworkManager.singleton.npcPrefab);
npc.GetComponent<PlayerName>().playerName = "NPC"; npc.GetComponent<PlayerName>().playerName = "NPC";
npc.GetComponent<CharacterController>().enabled = true; npc.GetComponent<CharacterController>().enabled = true;
npc.GetComponent<PlayerMove>().enabled = true; npc.GetComponent<PlayerMove>().enabled = true;

View File

@ -13,6 +13,9 @@ public class TestNTNetworkManager : NetworkManager
// have to cast to this type everywhere. // have to cast to this type everywhere.
public static new TestNTNetworkManager singleton { get; private set; } public static new TestNTNetworkManager singleton { get; private set; }
public GameObject botPrefab;
public GameObject npcPrefab;
/// <summary> /// <summary>
/// Runs on both Server and Client /// Runs on both Server and Client
/// Networking is NOT initialized when this fires /// Networking is NOT initialized when this fires
@ -46,15 +49,13 @@ public void OnSelectServer(int server)
#region Unity Callbacks #region Unity Callbacks
/// <summary> #if UNITY_SERVER
/// Runs on both Server and Client
/// Networking is NOT initialized when this fires
/// </summary>
public override void Start() public override void Start()
{ {
#if UNITY_SERVER
if (autoStartServerBuild) if (autoStartServerBuild)
{ {
// set default sendRate, then let CmdLineArgs override
Application.targetFrameRate = 30;
ProcessCmdLineArgs(); ProcessCmdLineArgs();
((SimpleWebTransport)Transport.active).sslEnabled = false; ((SimpleWebTransport)Transport.active).sslEnabled = false;
((SimpleWebTransport)Transport.active).clientUseWss = false; ((SimpleWebTransport)Transport.active).clientUseWss = false;
@ -64,16 +65,16 @@ public override void Start()
// only start server or client, never both // only start server or client, never both
else if (autoConnectClientBuild) else if (autoConnectClientBuild)
{ {
// set default sendRate, then let CmdLineArgs override
Application.targetFrameRate = 60;
ProcessCmdLineArgs(); ProcessCmdLineArgs();
((TestNTNetworkAuthenticator)authenticator).SetPlayername($"Bot[{sendRate}] ", true); ((TestNTNetworkAuthenticator)authenticator).SetPlayername($"Bot[{sendRate}] ", true);
((SimpleWebTransport)Transport.active).sslEnabled = true; ((SimpleWebTransport)Transport.active).sslEnabled = true;
((SimpleWebTransport)Transport.active).clientUseWss = true; ((SimpleWebTransport)Transport.active).clientUseWss = true;
StartClient(); StartClient();
} }
#endif
} }
#if UNITY_SERVER
void ProcessCmdLineArgs() void ProcessCmdLineArgs()
{ {
foreach (string arg in Environment.GetCommandLineArgs()) foreach (string arg in Environment.GetCommandLineArgs())
@ -187,7 +188,7 @@ public override void OnServerAddPlayer(NetworkConnectionToClient conn)
GameObject player; GameObject player;
if (authData.isBot) if (authData.isBot)
player = Instantiate(spawnPrefabs[1]); player = Instantiate(botPrefab);
else else
player = Instantiate(playerPrefab); player = Instantiate(playerPrefab);
@ -287,7 +288,11 @@ public override void OnStartServer()
/// <summary> /// <summary>
/// This is invoked when the client is started. /// This is invoked when the client is started.
/// </summary> /// </summary>
public override void OnStartClient() { } public override void OnStartClient()
{
NetworkClient.RegisterPrefab(botPrefab);
NetworkClient.RegisterPrefab(npcPrefab);
}
/// <summary> /// <summary>
/// This is called when a host is stopped. /// This is called when a host is stopped.