Exemple #1
0
    public GameObject CreatePlayer(int userID, int entityID, Vector3 pos, Quaternion quat, bool actor)
    {
        GameObject       obj = null;
        EntityAttributes ea  = null;

        //Other players
        if (actor != true)
        {
            obj = Instantiate(otherplayer, pos, quat);

            ea = obj.GetComponent <EntityAttributes>();

            ea.ID = userID;
            ea.ID = entityID;

            if (playerArray.ContainsKey(ea.ID) == true)
            {
                Destroy(playerArray[ea.ID]);
                playerArray.Remove(ea.ID);
            }


            playerArray.Add(ea.ID, obj);

            return(obj);
        }

        // Current player
        obj = Instantiate(player, pos, quat);

        ea          = obj.GetComponent <EntityAttributes>();
        ea.ID       = userID;
        ea.EntityID = entityID;

        CameraFollower cam = Camera.main.GetComponent <CameraFollower>();

        if (cam != null)
        {
            cam.SetCameraPosition(obj.transform.position);
            cam.target = obj.transform;
            cam.SetOffset();
        }

        playerArray.Add(ea.ID, obj);
        return(obj);
    }