Author Topic: Create localPlayerPrefab and remotePlayerPrefab  (Read 800 times)

DioAlias

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Create localPlayerPrefab and remotePlayerPrefab
« on: September 20, 2017, 03:40:10 AM »
If I use [RCC] - I can create one example of gameObject, but I need create localPlayerPrefab and remotePlayerPrefab - it is possible?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,152
  • Toronto, Canada
    • View Profile
Re: Create localPlayerPrefab and remotePlayerPrefab
« Reply #1 on: September 24, 2017, 01:24:12 AM »
You can pass the creator player ID as a parameter to your RCC function. Inside the function you can spawn one thing if it's the player ID matches, and another object if it doesn't. Remember, you can pass an empty string as the name of the prefab. It will work fine.

DioAlias

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
Re: Create localPlayerPrefab and remotePlayerPrefab
« Reply #2 on: October 10, 2017, 12:07:58 PM »
by this code my player from Editor don't synchronizing with othe player from build PC, but between PC builds all work is fine. it is possible to fix this? - my client from Editor can't send RFC to player(on PC build)

  1.     IEnumerator CreationPlayer()
  2.     {
  3.         while (TNManager.isJoiningChannel) yield return null;
  4.         if (channelID < 1) channelID = TNManager.lastChannelID;
  5.         Transform pos = GetStartPosition();
  6.         TNManager.Instantiate(channelID, "CreateAtPosition", "", false, pos.position + (Random.insideUnitSphere * 2), pos.rotation, TNManager.playerID);
  7.     }
  8.  
  9.     [RCC]
  10.     static GameObject CreateAtPosition(GameObject o, Vector3 pos, Quaternion rot, int id)
  11.     {
  12.         if (id == TNManager.playerID)
  13.         {
  14.             //Debug.Log("Local");
  15.             GameObject go = Instantiate(Resources.Load("Player3")) as GameObject;
  16.             Transform t = go.transform;
  17.             t.position = pos;
  18.             t.rotation = rot;
  19.             return go;
  20.         }
  21.         else
  22.         {
  23.             //Debug.Log("Remote");
  24.             GameObject go = Instantiate(Resources.Load("Player3(Remote)")) as GameObject;
  25.             Transform t = go.transform;
  26.             t.position = pos;
  27.             t.rotation = rot;
  28.             return go;
  29.         }
  30.     }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,152
  • Toronto, Canada
    • View Profile
Re: Create localPlayerPrefab and remotePlayerPrefab
« Reply #3 on: October 19, 2017, 01:48:12 AM »
You should not be using "lastChannelID" outside your RCC or RFC functions. You are using it inside a couroutine where the value of it is undefined. Replace it with an actual proper ID and everything should work as expected.