Arvutiteaduse instituut
  1. Kursused
  2. 2020/21 kevad
  3. Arvutigraafika projekt (MTAT.03.328)
EN
Logi sisse

Arvutigraafika projekt 2020/21 kevad

  • Main
  • Projects
  • Topics
  • Results and Schedule
  • Formatting Hints
  • Links

Flying Spaceship VR vol 2

Kertu Toompea

Final build - ship in Unity scene with gamepad controls - download

Preview of a simple movement gameplay:

Simple movement gameplay

Project Description

This project is about creating a nice-looking spaceship that you can fly around with a simple controls in VR. The nice-looking here means that instead of some white rectangle block flying around, the ship actually looks like a spaceship, has curved shapes and nice applied textures on it. It will not have realistic flight physics. The work of this project will teach a beginner to use the tools and apply some Computer Graphics course recipes to be creative.

Starting point - old project with block-looking ships:

Starting point - block-looking ships flying around

Too complex - this project will not output that high level ship:

Too complex - Normandy SR2 (source: devianart.com)

Something like this I am targeting to achieve:

My seemingly realistic target level - A low poly X-Wing ship (source: blenderartists.org)

By the end of this project here will be a link to the final build/repo and a 10-20s final result video.

Goals

  • Flying spaceship in VR
  • Ship has nice curves and textures
  • Ship is controllable with a keyboard and an Xbox controller

Tools

  • Unity
  • Blender
  • HTC Vive compatible (unless my favorite Oculus will change its FB-account-required policy, then prefer Oculus Rift)

Foreseen difficulties

  • Using needed tools well in Linux (if will be the case, will find and switch to a Windows machine)
  • Big time consumption to try out many seemingly simple things
  • Avoid distractions (temptation to dive into c# code in Unity, temptation to try it all also in UE to compare with Unity, temptation to start creating a beautiful world around the spaceship instead, etc.)

Milestone 1 (05.03)

  • Get all needed tools working in Linux
  • If necessary, set all the tools up in Windows
  • Have a VR compatible simple world with a plane and a flying rectangle block ready (the starting point of creating my actual nice-looking ship)

Progress:

The progress seemed to go smoothly with getting all needed tools working in Linux. After creating a new project, adding a plane, initial cube-ship and materials for the plane and the ship, everything seemed fine. Until I added a simple script for controlling the movement of the ship. Then I started to get errors and I could not move my ship with any controls. Some errors were easier than others. But one error remained and seems to be a bug.

Example of the status in Linux:

Unity error in Linux after attempting to run a script to control a game object

What I tried to understand and fix this:

  • I simplified my script to have only the basic lines of code that were written in the Unity manual for controlling a game object. Still no change.
Script code example of a simple object movement
  • I tried few other versions of Unity (instead of 2019.4.21f1) to see if the problem persists. At least in one version (2019.1.10f1) the error does not appear but the game object does not move either.
Unity ver 2019.1.10f1 without error but still no movement
  • I read about the problem in Unity dev forums and it appears to be a bug. Some newer versions of Unity were suggested as a one possible solution but those versions were not marked stable on the Unity product page. Also it was not fully clear from the forum that the problem does not appear AND the rest of the functionality is also problem free. According to the forum my version should not have this problem but in reality it has.

Unity forum: https://forum.unity.com/threads/buggy-editor-since-version-2020-1-13-x-server-freezes-when-opening-moving-layout.1032868/

After several tries with different versions of Unity I am too much out of time to delivery my planned M1 as expected.

Time consumption: 7.5h

I am switching to Windows. Unfortunately.

Milestone 2 (19.03)

Missed. (run out of time)

My takeaways:

  • Don't do spaceship controls with VR hand controllers. It's not comfortable or intuitive. I don't like it at all.
  • Use Xbox controller to fly a spaceship.
  • No real advantage in using Unity's new Input Manager approach. The old one does the job just as good.
  • Watch out for Unity crashes. You are never safe unless you save your work often.
  • Don't waste your time on the wireless HTC Vive connection problems. Use a wire.

Milestone 3 (09.04)

  • M1 (in Windows)
  • Gameplay video screen recording
  • My ship's first low poly element ready in Blender

Progress:

I experimented with the old and the new Input System in Unity. Eventhough the new system was not intuitive at all and hard to understand, based on the tutorials I did not want to go back using the old one. The main difference that makes it worth to use the new input system, is that instead of writing code for every different type of added controller (keyboard, gamepad, etc.) you define an action and simply add different controller inputs to it.

The new Input System seems to work fine in both, Linux and Windows.

New starting point with a block ship and a cinemachine free look camera:

New starting point - block-ship with a cinemachine free look camera

Script status to move around:

Script status with new input controls

Tutorials that helped:

20min - Unity 2020 - New Input System - Move and Rotate Object with Gamepad

9min - Why You Should Use The New Input System In Unity + Overview

20 min - Unity 2020 - New Input System - Move and Rotate Object with Gamepad

4min - How to use the NEW Input System with Cinemachine in Unity

While experimenting with different Unity versions, it's worth to note:

  • Different VR enabling from Unity 2019.4.x (project settings >> XR plugin management. Instead of  Player settings)
  • Different VR support type from Unity 2020.2.x (OpenXR)

Problems:

  • I run out of time in VR lab and did not record the screen video
  • I run out of time with diving into Unity input system and did not manage to model anything in Blender.

Time consumption: ~8h

Milestone 4 (22.04)

  • Gameplay video screen recording (from M3, in VR)
  • My ship's first low poly element ready in Blender (from M3)
  • Ship moves facing the direction - strafing

Progress:

Unity version: 2021.1.3f1

Screen recording of a simple gameplay in vr:

Simple cube ship fly in VR with gamepad

My first low poly element in Blender:

First low poly spaceship element in Blender - body

Tutorials that helped with Blender:

14min - Blender Tutorial: Spaceship (Quick Method) (A surprising method to create a cool spaceship from text. Tempting but I will still stick with the x-wing idea.)

14min - creating a spaceship in blender 2 8 (Just for inspiration. Not for beginners.)

10min - Blender 2.80 Tutorial - Add Background Blueprint Images Like A Pro (very useful)

3min - Beginners Blender 3D: Tutorial 7 - Modelling with the Mirror Modifier in Blender 2.82 (very useful for how to start with mirror mode)

The ship moves facing the direction but this is not strafing. I misunderstood strafing last time. Right now the ship moves facing the direction manually, e.g. using rotation in addition to movement. Strafing is a term that I am not sure about any more and I will avoid using it until I find a trustful enough source for it. I will come back to a more elegant movement after some progress in Blender to beautify my ship.

Tutorials that helped with VR for HTC Vive:

https://docs.unity3d.com/Packages/com.unity.xr.mock-hmd@1.0/manual/index.html

https://docs.unity3d.com/2021.1/Documentation/Manual/configuring-project-for-xr.html

Also:

During the process I changed the project's Unity version again. To what is currently the newest - 2021.1.3f1. This was after experimenting with the new input system, going through many guides and videos and in the hope of more developed and less buggy Open XR. The Open XR is needed for HTC Vive which is also used in this project.

Problems:

  • The new Open XR is still in development and sometimes the documentation is missing or refers to components that don't exist in the newest Unity versions any more.
  • There are many (even too many) tutorials about the older versions of Unity and how to set up inputs and VR related stuff. But there is almost no fresh tutorials that are up to date with the newest Unity version that are as useful as the old ones. Also many tutorials with different plugins that are not necessary to use if the new Open XR support is ready. I wanted to avoid all unnecessary plugins and prefer to use the new Open XR options as much as possible.
  • Blender progress is much slower than I expected. All those <10min video tutorials created an illusion that it goes fast but getting to the point where you understand how to add background or reference images, how to start with mirror mode modeling and how to do all the editing - selecting - view switching, took me hours, not minutes. But it's getting better now!

Time consumption: ~10h

Milestone 5 (07.05)

  • My low poly ship improved further in Blender (all elements are there, even if still bulky)
  • The cube ship in the game is replaced with the new low poly ship from Blender

Progress:

Unity version in Windows: 2021.1.5 Unity version in Linux: 2021.1.6f1

I finally have something looking like a real spaceship. I'm quite happy about the result. But it was not flawless. And I have more questions than before starting this milestone in Blender. The details about creating things in Blender are opening like a pandora box for me. I solve one thing and it creates at least two new things to struggle with. But I like it. Here are some images for this milestone:

My bulky X-Wing in Blender
My bulky X-Wing in Unity

Tutorials that helped with Blender:

Problems:

  • I had to learn some things all over again in Blender as I left too big gap between working on my ship from the last time. I should have learned this lesson by now already.
  • Cutting in Blender is hard. It's difficult to get the cut just right if the element is something more than a simple cube.
  • Selecting a face (or anything) in Blender that is in between or behind other objects is tricky. I didn't find an easy and reliable way to do it, except just hiding other objects and/or moving them apart so they are not in my way. But no idea how to do it if I for some reason cannot move different objects apart to separate them.
  • I broke something in Unity again. I switched to a newer version because of an update in OpenXR which I am really looking forward to develop faster, and now the VR game scene does not go into my headset any more. With the community help I finally found out that some OpenXR things don't work with DirectX12, and need only DX11. But the last thing I found out before leaving the VR lab was that I indeed have DX12 there. There is no good way to downgrade DX. I need to change Unity player settings so only DX11 is used and try if it's enough to solve the problem. If not enough, I may need to switch back to an older version or fiddle with Steam XR plugins to try to get it working again.

Time consumption: ~8h

Milestone 6 (21.05)

  • Get my VR game scene working again in the Vive headset
  • Apply some textures to the ship
  • Optional: If extra time left, then beautify the ship and/or maybe a bit the world around it to fly around

Progress:

Unity version in Windows + Linux: 2021.1.7

My VR game scene is working in the (wired) Vive headset and I have some modest texture on my ship.

X-Wing in VR
X-Wing in Blender with some textures
X-Wing in Unity with some textures

Tutorials for procedural textures in Blender:

Procedural Rust in Blender 2.8:

Procedural Scratches in Blender 2.8:

How to Bake Textures in Blender and Export to Unity:

Problems:

  • Could not get my VR scene working in the wireless Vive headset any more. Works flawless in the wired Vive headset though. Spent too much time troubleshooting this.
  • Created cool rusty texture in Blender but could not bake all for exporting to Unity. Only the bumps (normal) succeeded to bake. Tried all bake types in Blender with the render engine 'cycles'.

Time consumption: ~15h

  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused