Based on the ideas we discussed as a group, I created a test scenario in unity to consider the possibilities of implementation. This is a one-way transmission mechanism with only two rooms, an initial implementation
2.9 Further iterations of the project idea today
-Three rooms and two portals have been added
-The room shown in the portal is different from the actual portal destination
– The rooms are divided into blue, yellow and, at the very beginning, grey, with two portals in each room. Each portal renders an interior scene of the other two rooms depending on the player’s location. However, when the player passes through the portal, the location of the teleportation is not the room as the player sees it, which needs to be used in conjunction with the sounds that follow
Current issues:
1. As seen in the video, when the player approaches a portal in one room, the camera also renders a view of the portal in another room, which can cause confusion for the player.
2. The display screen of the camera’s render plane crosses to the outside of the room at certain locations, as the position of the camera in the room needs to be adjusted to correspond to the player’s position, so the position of the room setup becomes quite important, especially if there are 27 rooms to be set up afterwards.
3. When the teleportation occurs, there is a frame where the whole screen is flashing grey before the teleportation occurs, I tried to place the player in that position and eventually found out that it was because the player’s camera had passed through the wall of the original room a second before the collision occurred
2.13 Portal 3 Room Demo For Sub1
I made some changes to the scene to fix the previous problem.
1. I set up a collision detection mechanism to determine if the player is in the current room. When the player is in the current room, the portal in the room will only show the image rendered by the camera, and when the player leaves, the image rendering of the portal will stop, so that when the player sees another room from one room, it will not show the rendered image of both planes.
2. I adjusted the position of some cameras and collision planes, which reduces some problems during the portal through the model, but there are still some planes that have this problem during the portal.
Code explanation of function implementation:
Camera Follow
This part of the code is to make the camera set in another room follow the player’s position, and the portal is the base point to get the player’s offset value so that the camera moves to the corresponding position.
Some of the commented code in this section is intended to investigate the rotation of the camera following the player’s view, where quaternions are used to obtain the corresponding rotation angle, but it did not show good results in tests, so it was not applied at this stage, but as a direction for future research.
Camera Render
Shown here is how to use code to manage the image rendering material for multiple cameras. As the current camera tracking script does not implement rotation with the view, it is necessary to set up multiple cameras with different angles. Image rendering showing the plane of another room is achieved in this way.
Player Detect
This is a simple script to determine if the player is in the room and when the player leaves, the portal will stop rendering the image.
Teleport
This is a teleportation script that determines whether the player has crossed a plane by calculating the distance between the player and the door when the player collides with a collision body set up by the portal, and teleports to another place when the player crosses the plane, where the offset value of the rotation angle is also calculated by quaternions so that the player does not turn in another direction after teleportation.
The next plan:
I am going to optimize the camera’s player following logic, currently the camera can only follow the player’s movement, after that the idea is to be able to follow the rotation of the player’s head, but I have encountered a lot of problems when dealing with this part, as shown in the comments of the code, I have done some research on this part, but it is not working well at the moment.
Reference:
Mini First Person Controller
https://assetstore.unity.com/packages/tools/input-management/mini-first-person-controller-174710
Portal Tutorial
https://www.youtube.com/watch?v=cuQao3hEKfs&t=1282s