As first task for today, I'd like to implement proper input handling for portal control.
Moving between platforms should be a core part of the gameplay, and so opening or closing a portal should be robust, quick and easy.
Let's try binding the "portal opened" state to a very simple gesture, but to be made with both hands, so it should be easy to detect but hard to do by mistake.
Pretty reliable, definitely good for now. Notice that I have changed the activation logic: until now, you performed a pinch to open, and a pinch to close. Now, the portal opens and stays open only while you keep both hands open and with fingers up (and closes otherwise).
It is now time to change the target platform selection logic. My first idea was basing the selection on the triangle you were located when opening the portal (picking the opposite direction).
While testing, it's obvious that this doesn't work well: when you are near the center of the platform, it takes just a little to change triangle, and it's easy to to pick the wrong direction. Additionally, the target platform highlighting is misleading, because you can walk to one of the two adjacent triangles on "your side" of the portal and highlight their opposite platform. That's confusing. I've taken a short clip to illustrate these problems.
So, let's try to improve on both fronts.
For target platform selection, considering the orientation of the head and hands, and not only the triangle, could work better.
About platform highlighting/feedback for the player, it's time to decouple two concepts:
what would the target platform be if I opened the portal now?
which platforms are linked by the opened portal?
It's a good moment to solve another related problem.
Currently, it is (and it should be) possible to teleport "backwards", taking a step back across a portal. Of course, assuming that
you have an available platform behind you
you are standing on the "second half" of a platform when you open the portal
If you don't see a target platform straight ahead, it implicitly means that you are in the "second half" of the platform and so that the portal would open behind you (if possible), but there's nothing that lets you know if, in a certain moment, there is or not an opened portal behind you.
So, let's get rid of the red platform highlight (my eyes will be thankful) and introduce some other visual element that lets you understand
which is the current selected target, if any
if there's a portal opened behind you
I ended up adding some indicators on the side of the platforms, and they "slide out" together with the portal.
So, if you are opening a portal behind you, you can see the indicator sliding out in front of you.
For the platform selection, at least for now, I only used the forward camera vector to select between the candidate platforms.
As you can see in the video, depending on the player position on the platform, three candidate targets are selected. The current triangle is now used only to virtually cut in half the platform, but - from the same standing position - not one but three platforms are now reachable, depending on where one is looking.
In the video, the white segment is the camera look direction, and the three R/G/B lines connect the camera to the center of the three candidate platforms.
Then, using the dot product between the camera vector and each of these three vectors, we select the "closest" to the gaze direction.
Not perfect, but good enough for now!