Make sure, all of the following requirements are met:
- Unity 2019.4 or higher installed
- nodejs 14.16.1 or higher installed
Clone the repository to the desired location on your machine. A folder named awt-unity should be created.
git clone git@git.tu-berlin.de:alex94/awt-unity.git
Use either Unity Hub or the Unity editor to open the project (select the folder created by the git clone command). The first opening may take a while since Unity has to import all assets and packages.
Inside the Unity editor open the Project View. (ctrl + 5 or Window -> General -> Project)
Navigate to Assets -> Scenes and open the Prototype scene.
If you plan to use the gyroscope and https, you don't have to change anything.
If you want to use http instead of https, you have to configure the project as follows. Change the Signaling URL of the Render Streaming script of the RenderStreaming game object to http://localhost:8080
The default configuration is for https. You don't have to change anything on the web server for https to work.
Open a terminal or console window inside the WebApp folder. Run the following commands in this particular order:
npm install
npm run build
NOTE: The gyroscope does not work without HTTPS
Navigate to the WebApp folder inside the awt-unity folder. Open the package.json file. Change the start script (scripts -> start) to
node ./build/index.js -p 8080
.
Open a terminal or console window inside the WebApp folder. Run the following commands in this particular order:
npm install
npm run build
To run the application without the Unity editor and any visible game window, you have to build the application using the Unity standalone player.
Inside the editor, click on File and Build Settings.... Select your target platform click on Build and select a folder, where you want to save your application.
Start the web server by executing the following command inside the WebApp folder:
npm run start
To verify the web server is running, open the URL localhost:8080 in a browser. Add https:// in front of the URL in case you are using HTTPS.
You can change the streamed resoultion by editing the Streaming Size of the Adjustable Camera Streamer script on the PlayerCamera game object. To start the application from inside the editor, click the play button inside the Unity editor.
Alternatively, you can run the .exe, you created when setting up the batchmode. For that, navigate to the folder of the .exe and execute the following command:
.\Prototype.exe -batchmode
The application will run in the background. To close it down, simply use the Task Manager to kill the process.
To change the resolution when starting the application in batchmode you can use the following command:
.\Prototype.exe -batchmode -streamingWidth=YOUR_WIDTH -streamingHeight=YOUR_HEIGHT
The default width is 1280 and the default height is 720.
On the website at localhost:8080 click on Open Video Player.
Click the play button of the video player on the next site.
You can now
- control the character with WASD
- move the camera while holding down the right mouse button
- control the character with the left stick of a gamepad
- control the camera with the right stick of a gamepad
- control the camera with the gyroscope (either by tilting the phone or using developer tools in certain browsers)
- control the character by touching the upper, lower, left or right part of the streamed video
Multiple client devices can connect to the same video stream. However, only the first client can control the character and the camera. If the first client disconnects, the first newly connected client receives control.
Make sure the web server and the application are NOT running.
In case the port 8080 is already occupied:
- inside the Unity editor, select the RenderStreaming game object. In the inspector, change the port number under Render Streaming -> Signaling URL.
- inside WebApp folder open the package.json and change the port number in the start script to the same number as in Unity.
Problems with https and the certificates:
- replace the content of client-1.local.crt and client-1.local.key inside the WebApp folder with your own certificate and private key.
- alternatively, you can change the location of the certificate and the key by editing the package.json inside the WebApp folder. Inside the start script, replace client-1.local.key and client-1.local.crt with the paths to your key/certificate.
When using the gyroscope, the camera spins rapidly around on a certain angles. This is due to the so called gimbal lock.
In batchmode, the mouse and the right stick of the gamepad are not working. This is most likely caused by weird interactions with the batchmode and the new Unity Input System.