- Home /
Creating Multiple Game Screens
Greetings,
I am tryin to create a multiplayer room based game which the players can join multiple rooms at same time. Every rooms need to have big space like infinity.
I will create a invidual new tab for every rooms when a player select a room and join in game.
I have a long time experience as desktop software developer. Thats why i'm thinking i need to handle screen as an object to achieve this. Create a new screen as object, place game objects, set scripts and play.
It's highly possible to interfere rooms each other or possbile to reach to other rooms if i place all of rooms in same screen (i cant set border lines to limit players movements). Thats why i have to draw every rooms individually.
But still i dont have any idea how to create a new game screen and can i show or hide it when user changes the tabs.
Is this possible with Unity without loading scenes in same screen?
Best Regards,
If by scenes you mean the files, then no. It's only one. However, if by scene you mean the rooms, then it's fine. You can have 4 rooms in different places, and 4 cameras each looking at one room, and each camera is rendering at one portion of the screen. So you can be looking at all 4 cameras at the same time. The file you'll save on your project though will be just one. But you can have multiple prefabs and activate which ones are suitable at the time.
(Hint: with Unity you need to refer to the stuff by their right name. If by scene you meant the view of the player, then call it view, or room, or level... because in Unity scenes are the files containing the data for a level lets say.)
Thank you for your answer,
You are right, i should use "rooms" ins$$anonymous$$d of "scenes".
Having all the rooms in same space is not possible in my case. As i said; rooms can interfere each other or player can reach to other rooms in free move mode (i cant set border lines to limit players movements). Only way is drawing one room on screen but still other rooms have to be alive.
And yes, me too thinking putting all room objects in a prefab which created on runtime and show or hide prefab. But this is a avatar based game, thats why im thinking handling prefabs on every changes will be cause a big performance loss.
Best Regards,
Answer by Alessio89 · Aug 24, 2014 at 11:48 AM
Your logic is pretty good and indeed treating "screens" as objects is a diffuse technique. But sadly (as far as I know) unity isn't really suited for this kind of logic. You would have to code that yourself, handle the different screens and decide what's visible and what's not (maybe give a tag to every object to determine in what screen they should be drawn? And then have a general screen manager that decides what to draw based on what screen the player is in... The possibilities are infinite if you want to invest some time in coding them).
I don't understand, however, why you can't use different scenes for different rooms? If that's because you need to pass over some gameobject to a new room, you can always use DontDestroyOnLoad(GameObject object) so that when you switch scene the object stays there.
Thank for your answer,
There is 2 reason to explain why i cant use differet scenes; 1-) Rooms are creating by data files at runtime. I mean i dont have any pre created scene (player can edit the room freely). 2-) I have to keep alive all the rooms at same time. I can only hide and show the screen.
Additionally, I cant use same scene to draw all rooms as game objects because room sizes are flexible (unpredictable) and have own cameras and scripts. It will be really shameful for me if player can discover other opened room on free move mode :)
Best Regards,
A solution then would be as I mentioned early. $$anonymous$$eep a static manager class that handles what is visible and what not for the local player. For example you could have a tag for each room and every item in that room will have that tag. In the manager class you keep a variable to store in which room the player is in and then hide everything that's not tagged for that room. Never done this myself, but this is what I would try first to see if it's doable that way :)
Thank you,
Your idea sounds like its possbile to be useful. I will try to learn about tags.
But something confusing me. Will scripts, animations or on air sounds continue to their process when i hide the room together its objects?
Best Regars,
If you disable the whole object, yes all the components included (audio sources, scripts, controller, renderers) will be disabled. If the gameobject holding the audio source have the right tag it will get enabled, otherwise it will stay off. There may be better ways of handling it, however. But I'm sure you'll figure it out as you go :)
Thank you,
I'm feeling like disabling will be bad :) Hiding is only way to solve my problem. I decided to try your advice after reading documentations about tags and layers. But still it would be best if i could treat screen as object, create as much i need and handle at same time. Thank you again.
Best Regards,
Your answer
![](https://koobas.hobune.stream/wayback/20220613161341im_/https://answers.unity.com/themes/thub/images/avi.jpg)