Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

How can I program portals like actual vale portals in 2d?

Discussion in '2D' started by TextodeEjemplo, Jan 5, 2018.

  1. TextodeEjemplo

    TextodeEjemplo

    Joined:
    Jan 5, 2018
    Posts:
    5
    The main problem that I found programming the portals is the transition. In portal you can stay in the middle of a portal so you are half on one part of the screen and half on other part of the screen.
    Any idea on how can achieve that?

    Sry for my English guys:(
     
  2. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    In the real portal game what they do is simply create a copy of the model that is touching the portal, move it to the other portal, and of course clip the model (using real geometry clipping, or simply render clipping using the stencil buffer).

    Doing the same in 2D should be way easier because you can just mask the objects as they enter the portal (so they don't show behind the portal)
     
  3. TextodeEjemplo

    TextodeEjemplo

    Joined:
    Jan 5, 2018
    Posts:
    5
    Wow,Really? I didn't know that portal worked that way.
    I thought about that and I'm already doing that thank you so much
     
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    If i remember correctly there is a talk/video or maybe even some presentation thing somewhere on the internet about that.
    I remember that they went into all sorts of technical details of how they use the stencil buffer and what they have to do to make sure not only object rendering is suppressed behind the portals, but also making sure the physics engine doesn't flip out (because you'll have objects that are stuck inside the wall, and they shouldn't get "ejected" of course)

    Maybe take a look at valves website or so if you want to know more :)