I am using for creating characters in game, normal prefabs.
But sometimes, it takes a few more seconds, depending on the map (I assume objects in scene, loading in Unity usually) and the objects to spawn via CreateEx.
So, if one character prefab is created with CreateEx call and I just start to use RFC, sometimes it says "Trying to execute RFC #17 on TNObject #16777215 before it has been created." - this is my movement command to update in all clients. If this happens, some clients can't see this character updates (the funny point is that other RFCs work, like chat commands, just everything with this character does not).
Sometimes it works, sometimes does not.
To fix this I made all players to wait a few seconds, check some variables and then I start to send RFC for movement and anything else from these created prefabs (characters) with CreateEx. But I think it should work, right? Because if it was created, it means it exists in scene and... normal RFCs can already be send.
If I had something to tell me, as a callback or something, that the object that I sent to create, was actually created, this would be better (or maybe I am doing something wrong here).
Script to send:
TNManager.CreateEx(12, false, _MissionSceneManager.Instance._charactersPrefabs[(int)_CharacterType.allyNpc], pos, rot, unitName, (int)charInfo._weaponPrimary, (int)charInfo._weaponSecondary, (int)charInfo._gadget1, (int)charInfo._gadget2);
Script received:
[RCC(12)] static GameObject _Receive_CreatePlayerCharacter (GameObject prefab, Vector3 pos, Quaternion rot, string unitName, int gun1, int gun2, int gad1, int gad2)
{
_SaveLog("NETWORK", "NETWORK: Received creation of player character - " + unitName);
//Cria personagem na tela
GameObject objCreated = (GameObject) Instantiate(prefab, pos, rot);
objCreated.name = unitName;
//Pega script e cria arma para ele
_CharacterPlayerController playerScript = objCreated.GetComponent<_CharacterPlayerController>();
//Pega items a dar para jogador
_ItemData playerGun1Weapon = _ItemsManager.Instance._itemsList[gun1];
_ItemData playerGun2Weapon = _ItemsManager.Instance._itemsList[gun2];
_ItemData itemExtra1 = _ItemsManager.Instance._itemsList[gad1];
_ItemData itemExtra2 = _ItemsManager.Instance._itemsList[gad2];
_CharacterData tempPlayer
= new _CharacterData
(); tempPlayer = Instance._networkProfileActive._soldiersList[0];
//CHECA ERROS
if (tempPlayer._alias == "")
{
_SaveLog("NETWORK", "ERROR: character to create NOT FOUND", 1);
return objCreated;
}
//Seta jogador local
playerScript._PrepareForStartLocal(tempPlayer, playerGun1Weapon, playerGun2Weapon, itemExtra1, itemExtra2);
//Seta armas do HUD
_MissionSceneManager.Instance._guiPlayerHUD_panelPrimary.sprite = _MissionSceneManager.Instance._itemSprites[(int)playerScript._characterData._weaponPrimary];
_MissionSceneManager.Instance._guiPlayerHUD_panelSecondary.sprite = _MissionSceneManager.Instance._itemSprites[(int)playerScript._characterData._weaponSecondary];
//AVISA EVENTOS
_MissionSceneManager.Instance._CallPlayerCreated();
//Reseta inputs
Input.ResetInputAxes();
//Debug
_SaveLog("NETWORK", "ONLINE Local player character created!");
return objCreated;
}
EDIT: tried both with "SendQuickly" and "Send", same result (tried also with persistent and not, same result)