Is it possible to set the player prefab as an UI element?

I’m creating a multiplayer Quiz game and I’m trying to set the player prefab as an UI element to then use the syncvar hook to change the name of the user in the UI.

but when Mirror automaticaly create the prefab player it set in the worldspace and not inside a canvas.

how can I change the parent of the player prefab from the client site?

Should I create a normal player prefab instead of an UI element and then set the values of the UI element using references?

Hi there,

You can set the parent of a transform via script using Transform.SetParent().

However, I think your second suggestion makes more sense. You don’t actually need the player as part of the UI. I would create a new class to take information from the player and handle setting up your UI.

Hi, thanks for the reply.

Is it possible for a client to access the list of connected players from OnClientConnect()?

how can I differentiate my own player from the others?

Thanks

Hi there,

You could do a foreach loop over FindObjectsOfType(). Basically run through all the players in the scene. Then you can check their connectionId to see if it matches the local one. We use the connection Id often throughout the course to distinguish different players, similar to how we check if Units belong to the local client.

Thanks

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms