- Home /
The question is answered, right answer was accepted
Game with 2 separate windows
I had an idea for a puzzle game, where you would play in 2 separate windows at once, and the windows would need to share actions across them, for example you stand on a button on one screen, and the doors open on the second one. But if you go to another room on one screen, it doesn't change on the second one. Is something like this possible? Also sorry if english bad, or something i wrote is unclear
Edit: I want to achieve something similiar to here (Spoilers for OneShot)
I don't have an answer, but I think you'll need to start 2 application when the game is opened. Application #1 write its state to a location on the hard drive, then application #2 continuously check that location for new state so it'll update to match application #1. Or instead of using hard drive, you can use Photon and make a local network for them to communicate.
Answer by Bunny83 · May 26 at 09:26 AM
Well, Unity itself does not support multiple game windows at the same time. Of course you can create your own native window using the windows API, but that's probably not what you want. The best alternative if you want to use Unity to render both windows is to start your application two times and have each instance display something different. You would need to use inter process communication or network sockets to communicate between the two applications.
Furthermore if you want the background of one of the windows to be transparent you have to utilize quite a bit of native windows api. Here's a package that may help you out a bit.
Though overall even it's not super complicated, it's not trivial either. The game you linked has this as a specific game feature / gimmick. This has countless of potential issues that could break the game. Depending on the windows version and the user's theme / style certain features may not exist at all or break in one way or the other. So such things would need to be tested on a variety of systems. Also be careful what you're doing on the user's PC. The game you mentioned does also manipulate all sorts of system settings like the desktop background image. If you're not careful and restore the original state, players will be quite upset. So you should know what you're doing.
You can "simulate" a window inside the game itself. Of course it would not be a seperate OS window but contained inside the gamewindow. However this should be much easier and less error prone. You haven't been very clear on what you want to use that second window for. You said you have an idea but you mostly described that OneShot game. So do you actually have a concrete idea what you want to use that second window for? Or is it just because this game did it so you want to do the same thing? On of the hardest parts of game development is to have a good game design. I have the feeling you're stabbing in the dark and only have a very very rough idea what you actually want to do and why.
Your initial description just sounds like a classical split screen game with two characters and each has its own view. This does not require a second "window". Here's one of my very old WebGL examples that was about a vis portals implementation, but it featured an "overview window" which was a second camera that was looking straight down. To look around you have to hold down the right mouse button. This is a bit glitchy inside the browser. Anyways I added a button to swap the two views. So you had the FPS view in the tiny window and the overview as the main view.
If you insist in having two seperate OS windows, there's a lot you have to take into account in order to visually align the content of the two windows like it was done in the OneShot game. Different windows versions and themes have different border and title bar sizes. So in order to match the coordinates you have to jump through several hoops. As I said it's not super complicated but not really a thing for a beginner.
So first thing is, when I linked that OneShot clip I only meant the two windows thing, not the puzzle itself, and it was only place i remembered a game doing this.
And the examples of what I want possible in this game were pretty bad. When it comes to things, thar require two windows, I was thinking like you have to align them correctly, so a box you push off the ledge on one window falls into the other one, otherwise it falls "outside", and you can summon another one to try again. Or you need to close one of the windows, to stop water from flowing and blocking the passage.
And also you're probably right. It's more of a rough sketch, rather than an concrete Idea and I am stabbing in the dark. I should probably try doing something much simpler.
Anyways thank you for your answer.
Answer by simiel7 · May 23 at 09:48 PM
Hi @ugyasludif
Isn't it what you want? Already answered question
Thanks for answering. Not really what I'm looking for. What I'm thinking of is like 2 applications running at the same time. Something like here in One Shot