Portal-able surface
The line going from the character to the aimed at point is showing the character’s line of sight to that point. Without this restriction the character could simply portal to the end of the level immediately.
When a portal is fired the game checks if the placement is valid by ensuring that all points around the portal are on a portal-able surface. Upon finding a invalid point the placement is then adjusted to ensure that the point becomes valid.
On horizontal surfaces, the portal instead keeps moving slightly toward the middle of the surface tile until finally valid.
Upon finding a valid placement the game checks if the two portals overlap, and if so removes the previous one.
For the angled portal-able surface I decided to always center the portal placement in order to make the momentum puzzle much easier. It will also carries along the portal whenever it’s tilting, instead of destroying it.
Portals
Whenever the portals are facing the same direction and the character steps through, the character will instantly turn around and go back into the portal again. To give the player some time to react to this, the portals pushes the character out of it.
This also helped to ensure the character dosn’t get stuck inside two horizontal portals.
The character always remains upright even though the portals would sometimes logically flip it upside down or sideways. A quick rotation back to upright could be implemented, but it would probably look weird and silly due to just how quick the rotation would have to be.
Even though the portal moves during a surface tilt, the character will exit with the correct position, angle and momentum.
The reasons for not being able to see through the portals are to save frames since it is already rendering the scene once per eye. Recursive portal renders in VR would be expensive. The other reason is because the portals are so small relative to the player, as well as often being viewed from far above. Meaning the player most of the time wouldn’t really see anything other than part of the immediate floor panel through the portal.
For portals with a view through, check out my Portal Test!