Search Unity

Third Party Custom Character Photon Transform View

Discussion in 'Multiplayer' started by ZarkaOui, Apr 29, 2021.

  1. ZarkaOui

    ZarkaOui

    Joined:
    Aug 20, 2018
    Posts:
    2
    Hello guys !!

    //Context :
    It's my first time posting on this forum so I really don't know what to expect. Thanks for reading about my issue that I'll try to describe in the most easy way.

    So, I wanted to prototype some very simple multiplayer game using Photon (I'm new at everything : Unity/Photon/coding).
    What I did then is watch a loooot of Youtube content (thx Brackeys and Infogamer) and try to give a shot.


    //My issue :

    I created a basic "Robot" character made of empty GameObject and some Cubes as follows :
    RobotPrefab.jpg

    As you can see, I attached 3 scripts :
    - "Brackeys Player Movement" will only move the character using the built-in CharacterController component from Unity
    - "Character Rotation" will just rotate the body like a robot, a bit asynched just like when you perform a robot dance with your mates :)
    - "Random Colors" that will just setup random colors to all the parts of the Robot.

    Everything is working fine locally.
    Theeeeen, I wanted this to be a multiplayer character hahahah ! What a fool...

    I'm using Photon PUN 2 so I attached a "PhotonView" on the root of the prefab (GameObject named "Robot").

    But here is the result when I instantiate it on other clients :
    RobotInMultiplayerScene.jpg
    Note : the editor is showing what I expected to be in-game !!! Holly molly

    I tried to add "Photon Transform Views" on every GameObject composing the Robot but the result is the same. It's not showing antennas/arms/legs and so on, only the head and torso :'(...

    I don't understand why... Is it a normal behavior ? What am I missing ?

    Also, here is the piece of code used to instantiate it through the network :
    Code (CSharp):
    1. using Photon.Pun;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.IO;
    5. using UnityEngine;
    6.  
    7. public class AvatarSetup : MonoBehaviour
    8. {
    9.  
    10.     private PhotonView PV;
    11.     public GameObject myCharacter;
    12.  
    13.     void Start()
    14.     {
    15.         PV = GetComponent<PhotonView>();
    16.         if (PV.IsMine)
    17.             myCharacter = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabsFolder", PlayerInfo.PI.AllCharacters[PlayerInfo.PI.mySelectedCharacter].name), transform.position, transform.rotation, 0);
    18.     }
    Thanks for reading through everything, hope I'm not the only one facing this kind of issue and someone already fixed it.
    Anyway, let me know anytime, I can provide all my code etc... ;)

    Kiss kiss !
     
  2. ZarkaOui

    ZarkaOui

    Joined:
    Aug 20, 2018
    Posts:
    2
    Oh my gosh...

    I am really sorry, I just found out about the issue....
    There is a script that changes the layers of my GameObject if it's not my PV so it makes it visible (by default my Camera doesn't render GameObjects of my player for obvious reasons).
    This script was defective and I didn't notice, only 1 depth children were changed into the right layer in order to be displayed...
    Sorry for embarrassing myself and bothering you lol !!

    See you.
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Glad you found the cause.
    Thanks for updating the thread.