private void InstantiateMyPlayer(ulong clientId)
    {
        GameObject      playerGo = Instantiate(m_playerPrefab, IVUtil.GetRandomSpawnPoint(), Quaternion.identity);
        NetworkedObject nObj     = playerGo.GetComponent <NetworkedObject>();

        nObj.SpawnAsPlayerObject(clientId);
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (m_allowMovement)
        {
            if (Vector3.SqrMagnitude(m_cachedTransform.position - m_nextTargetPosition) < 1f)
            {
                m_nextTargetPosition = IVUtil.GetRandomSpawnPoint();
            }

            m_cachedTransform.position = Vector3.MoveTowards(m_cachedTransform.position, m_nextTargetPosition, m_speed * Time.deltaTime);
        }
    }
    private void InstantiateServerNPCs()
    {
        if (!NetworkingManager.Singleton.IsServer)
        {
            return;
        }

        GameObject npcGo = null;

        for (int index = 0; index < m_serverNPCCount; ++index)
        {
            npcGo = Instantiate(m_serverNPCPrefab, IVUtil.GetRandomSpawnPoint(), Quaternion.identity);
            NetworkedObject nObj = npcGo.GetComponent <NetworkedObject>();
            npcGo.GetComponent <IVBasicPlayerAI>().enabled = true;
            npcGo.name = $"ServerNPC_{index}";
            nObj.Spawn();

            IVGameManager.Instance.AddNPC(nObj);
        }
    }
    private void OnConnectionApprovalCallback(byte[] connectionData, ulong clientId, NetworkingManager.ConnectionApprovedDelegate connApprovalDel)
    {
        bool approved = false;

        try
        {
            string receivedClientCode = System.Text.Encoding.ASCII.GetString(connectionData);
            if (0 == string.Compare(m_clientCode, receivedClientCode, true))
            {
                approved = true;
            }
            Debug.Log($"[MLAPI] Approved Client: {m_clientCode} receivedClientCode: {receivedClientCode}");
            ulong?prefabHash = SpawnManager.GetPrefabHashFromGenerator("FPSController");

            connApprovalDel(true, prefabHash, approved, IVUtil.GetRandomSpawnPoint(), Quaternion.identity);
        }
        catch (Exception ex)
        {
            Debug.LogError($"[MLAPI]:  {ex.Message}");
        }
    }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     m_nextTargetPosition = IVUtil.GetRandomSpawnPoint();
 }