UI on player or camera?

This is more of a conceptual question than asking how to do something. I have my player with a bunch of UI panels attached for things like inventory, combat, crafting, amd stuff like that. Since this is a multiplayer game (using photon) I will have many players but only 1 camera. Does it make more sense to put all the UI panels on the Camera instead of the player, or is it such a small issue that I don’t need to worry about it?

I suppose it depends on the game. If your using world space canvas that can be seen by every player (other players can watch a different player interact with ui) like probably a vr game or something - it might make sense to keep them in the player object so that can work properly. If you only want the player to see their own hud, as most regular games do, then perhaps attach to the single camera, and don’t network them.

The secomd example is what I am thibking of doing. It makes sense to me that things would be on the camera and not the player, just not sure if there is some unity limitation or networkimg limitation I am not aware of. Thanks for the advise!

Unless you’re talking about a world space UI, I always make the UI separate from both the camera object and the player object. There are times when you’d want to disable or destroy either the player or the camera, and it becomes a pain if your UI is part of that object.

1 Like

I hadn’t considered making the UI its own separate object. I just assumed it had to be attached to something. Hm maybe that’s a better way to make it work.

I’m assuming that will work multiplayer? So I can make just 1 UI object but it appears different for each player (as in displays player inventory separately)

That sort of thing (the multiplayer ui) is handled by your net code, and what each client can see depends entirely how things are setup, who the host/server is… and how your write the side of things that handles that.

I also always keep my canvas(s) as their own gameobject in the hierarchy, so that you can persist the UI through scenes and such.