How to display generated 2D player in network ?

Options
hi..
I am using PUN for spawning player. I am successfully instantiating 2D Image in network, after joining Room I can see just my player on screen. Other connected player in Room is available in hierarchy but it is not displaying on the screen and also not instantiating on assigned rect transform. So why connected player is not displaying ?
If I am draging that player in canvas then it displays on screen.

void StartSpawnProcess (float respawntime)
{
StartCoroutine ("SpawnPlayer", respawntime);
}
IEnumerator SpawnPlayer (float respawntime)
{
yield return new WaitForSeconds (respawntime);
Debug.Log (Spanpoints);
int index = Random.Range (0, Spanpoints.Length);
player = PhotonNetwork.Instantiate ("toprightplayer", Spanpoints [index].position,Spanpoints[index].rotation,0);
}


Is it possible using unity4.6 ui ? I have seen "Demo2DJumpAndRunWithPhysics" demo of PUN . It is developed using sprites.

Waiting for reply
thanks in advance

Answers

  • vadim
    Options
    Hi,

    So what is in "toprightplayer" prefab?
    Does you app works if replace prefab with simple box or with prefab from Demo2DJumpAndRunWithPhysics?
  • @vadim "toprightplayer" is prefab in which there is 2D Image which will be generate in canvas". 3D objects works well because its not need to add them in to canvas UI panel. but when i generate prefab which contains simple image with Rect transform property. it generated but not display its own position.
  • xXGriMe
    xXGriMe
    edited December 2015
    Options

    @vadim "toprightplayer" is prefab in which there is 2D Image which will be generate in canvas". 3D objects works well because its not need to add them in to canvas UI panel. but when i generate prefab which contains simple image with Rect transform property. it generated but not display its own position.

    Just set the text objects parent as the canvas.

    transform.SetParent(GameObject.FindObjectOfType<Canvas>().gameObject.transform, false);