0
\$\begingroup\$

Basically there are 2 windows that you can drag and drop around the screen. Whatever appears in one window will also appear in the other. The two windows cannot go one over the other.

enter image description here enter image description here

This is a demo for the mechanic: https://youtu.be/9U4Zoagd_40?t=83

I'm looking for a few steps in the right direction. How can something like this be implemented?

As I see from a comment below there are multiple parts to a mechanic like this, my focus for now would be 2) Making each rectangle display a superposition of the level content that's behind both

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Which step are exactly struggling with and what have you tried so far? \$\endgroup\$
    – Zibelas
    Nov 24 at 10:49
  • 1
    \$\begingroup\$ As Zibelas says, there are many parts to a mechanic like this. Just off the top of my head there's 1) Making two rectangles the player can drag around the map but not overlap, 2) Making each rectangle display a superposition of the level content that's behind both, 3) Treating solid obstacles in the window as solid obstacles in the level, 4) And so on for any other behaviours the windows should have. Each of those steps requires very different answers. Which one single step do you want help with? Edit your question to focus on one part - you can always ask another question later. \$\endgroup\$
    – DMGregory
    Nov 24 at 12:15
  • \$\begingroup\$ @DMGregory thank you for the answer, my focus would be on 2) for now. \$\endgroup\$
    – Shury
    Nov 24 at 12:19
0
\$\begingroup\$

Here's a sketch of how you'd accomplish the rendering look:

Make two extra orthographic cameras in your scene, moving and sizing each to capture the rectangle covered by one window. Set their layer so that they can see the level tiles, but not the windows themselves, the player character, or other things the windows shouldn't be copying. They should also probably not see the background (set their clear colour to transparent black), to help with the layering later.

Assign a RenderTexture to the target field of each of these cameras, so they save what they see into a texture.

Assign a material to each window's quad with a custom shader that blends together these two RenderTextures into a single semi-transparent image.

For efficiency, you can re-render the view from these cameras only when one of the windows moves, but re-rendering every frame also won't break the bank.

\$\endgroup\$
0
\$\begingroup\$

As for how you could implement 3) from the comment.

  • Have a duplicate actor that is invisible.
  • Once you enter the window, spawn the invisible one in the second window.
  • Disable control of first actor and control the invisible instead.
  • Let the first actor mirror the position of the second actor.
  • Hand over control to first actor once you leave the window.

This way you can handle as well interactions for 4). Spawn always an invisible object of whatever enters the window (like bullets) and handle the original the same way the invisible one gets treated.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.