Arvutiteaduse instituut
Courses.cs.ut.ee Arvutiteaduse instituut Tartu Ülikool
  1. Kursused
  2. 2021/22 kevad
  3. Virtuaalreaalsus (LTAT.06.019)
EN
Logi sisse

Virtuaalreaalsus 2021/22 kevad

Smooth Flight Spaceship

Introduction

Project focus: Smooth flight controls in Unreal Engine (UE)

Project goals:

  1. Learn how to create a VR game scene in UE
  2. Learn how to use Blender model in UE
  3. Learn how to implement flight controls in UE
  4. Learn how to smooth flight controls (main target: gamepad)
  5. If enough time, do the same in Godot. To compare and learn. >> Not doing.
  6. Final result: smoothly fly a spaceship in VR

Not doing:

  • Realistic physics (for example I plan to use no gravity)

The project is about learning how to create a calming VR flight experience in Unreal Engine 4. The experience will ideally look like this: you fly a spaceship above an uninhabited terrain with a gamepad and listen to some calm sound (engine sound, music or something similar). The flight controls are smooth and avoid aggressive movement. There is no fight, no death, no enemies, no possibility to “lose a game”. It is by definition not a game. It is a fly-and-relax experience.

In UE I will learn how to create a scene with some terrain, how to use my Blender ship model there and how to create flight controls. I have no practical experience with UE or Android Studio or Quest 2 so I start from scratch.

Story

I will consider the result somewhat a success if a stressed out or anxious person puts on a VR headset, sits in a comfy chair, flies around with the ship and after some time finds that this experience really was relaxing. For example it can take place after one has played a stressful war game or just an aggressive shooter in the evening but is then too stressed to go to sleep. Then tries this flight experience and hopefully calms down before going to sleep.

A feedback is appreciated and will be used for future anti-anxiety VR games. Flying in VR is also one of my favorites and I am looking forward to learn how to make it right.

Initial mockup

Initial visual mockup

Lab4 first scene with asset:

In the first UE scene with my ship model I added one external asset pack with a customized sky.

Initial scene with external asset pack GoodSky

Used asset: Good Sky by Uneasy Games

Deliverables

Draft deliverables for the 4 checkpoints:

1. March 14: Project set up in UE

  • Has at least a plane for the initial simple terrain
  • Blender ship model and the cockpit imported in the scene
  • Scene viewable in VR headset
  • Initial locomotion done based on lab5
  • Initial sound added for experimenting

2. April 4: Initial flight controls

  • It is possible to fly the ship but does not look good yet

3. April 18: Improved flight controls

  • The initial plane has some terrain look
  • An experimental sound added

4. May 2: Smooth flight controls

  • Improved terrain has some elements added (ready made free assets, for example rocks, trees, ruins etc.)
  • If decided in checkpoint 3, one of the following made:
a) Fly the ship in 3rd person view or 1st person view (ship or cockpit - only one chosen)
b) Fly the ship with a simple switching option between the 3rd person view and 1st person view

Progress of Deliverables

1. March 14: Project set up in UE

  • Has at least a plane for the initial simple terrain
  • Blender ship model and the cockpit imported in the scene
  • Scene viewable in VR headset
  • Initial locomotion done based on lab5
  • Initial sound added for experimenting

How it went

  • I used the VR template scene for the initial scene.
  • When importing the ship model, setting the materials seemed much more complex than in Unity. I left the model currently without the correct material so I can come back to it in a later lab. When importing the cockpit model, setting them to scale and fitting them well was not trivial. I left them a bit ugly so I can come back to it when beautifying things. Below I show some things I learned about getting a model from Blender to UE and correcting the dimensions for to half way solve the scaling issues.
  • The scene is viewable in VR headset Quest 2 and at least initially seems not broken.
  • The locomotion was the most time consuming and I got stuck in several places. First the teleportation. I tried to understand how to teleport to higher places in my custom scene correctly and after non helpful documentation got help from youtube. The higher places part got better after playing with the Agent Max Slope and Agent Max Step Height values in the RecastNavMesh-Default object and with increasing the z value in the NavMeshBoundsVolume object's scale transform settings. But the teleportation area is still not fully correct and looks weird in several places. Secondly the non trivial movement implementation. From the given options I chose the third person movement. For the flight controls had to cut from complex flight controls tutorials to the simplest movement. I got stuck with the related blueprint where I was not able to add needed turn rates even though they seem to be present in the input settings. Later I did the BP for a simpler movement but none of the keyboard controls seem to work yet.
Cockpit fitting difficulties
Weird looking teleportation area
Axis event for yaw rate?

Dimensions and scaling from Blender to UE:

In Blender. I corrected my ship dimensions so at least the ship length is approx correct (13.3 meters). Then I checked that the scale factor in Blender is 1.0.

Corrected ship dimensions in Blender

Exporting from Blender. I corrected the FBX export settings ensuring that only the selected mesh is exported and set the forward and up directions to X and Z accordingly for UE. Also the Apply Transform had to be checked. Then hit Export FBX.

FBX export settings from Blender

Importing to UE. In UE I created a separate folder for my ship model under the Content > Geometry > Meshes. Then Import Asset and from the opened dialog box changed the material import method to Do Not Create Materials and ticked Import Textures. Then with the Import Uniform Scale value I made a mistake. At first I left the value to 1.0. Then I got confused as I learned that UE standard unit is cm (who puts a standard unit to cm?!). So I corrected the Import Uniform Scale from 1 to 100, following the logic that 1m in Blender is 1cm in UE. But it was wrong. Also the other way around 0.01 is wrong. It had to be 1 and stay 1.

Wrong: UE import FBX result with Import Uniform Scale = 100
Wrong: UE import FBX result with Import Uniform Scale = 0.01
Correct: UE import FBX result with Import Uniform Scale = 1
UE import messages:
No smoothing group information was found in this FBX scene. Please make sure to enable the 'Export Smoothing Groups' option in the FBX Exporter plug-in before exporting the file. Even for tools that don't support smoothing groups, the FBX Exporter will generate appropriate smoothing data at export-time so that correct vertex normals can be inferred while importing.
ship_rusty_fixed_dimensions13_3m_scale1_exportApr08 has degenerate tangent bases which will result in incorrect shading. MikkTSpace relies on tangent bases and may result in mesh corruption, consider disabling this option.
ship_rusty_fixed_dimensions13_3m_scale1_exportApr08 has some nearly zero bi-normals which can create some issues. (Tolerance of 1E-4)

Weird behavior in UE navigation mesh:

After getting the teleportation area to look better (no artifacts with slopes) I saved and closed the project. When opening it again, it looked broken again. Some settings were changed. This was unexpected. Images:

Improved teleportation area
Broken again after save and reopening

I tested again. This time I changed the values in Project Settings -> Engine -> Navigation Mesh. The result was better but some values still seem to change after saving and reopening the project. It remains currently unclear to me why such behavior occurs. In this example the Agent Radius has changed from 10 to 35 after reopening the last save:

Difference in project settings and scene settings after reopen

Similar issue from 2015 answered here. The temporary solution to this glitch was to add a supported agent in the Navigation Mesh project settings and I tried it:

Added supported agent in the Navigation Mesh project settings

It seems to be the solution also today, 7 years later. It works now and the settings remain also after save and reopen.

Non trivial movement:

After preparing the inputs and the following blueprints from scratch, none of the keyboard controls still seem to work. One tutorial that I found most useful in the end is here.

Created movement BP to forward and right
Created movement BP for roll, pitch and yaw

2. April 4: Initial flight controls

  • It is possible to fly the ship but does not look good yet

How it went:

The initial movement chosen is the third person movement. I am following this guide here. I ran into a problem that none of the initially implemented keyboard controls work. I checked step by step as follows.

Project settings / Input for a simple WASD:

Basic check that the input settings exist and are OK

I have two blueprints, Pawn and Game. The Game BP is configured to possess the Pawn when the game starts (the Default Pawn Class is set to my pawn):

Game BP configured Default Pawn Class to use my pawn

The Pawn BP has a Static Mesh Component and it is assigned to be my ship mesh:

Pawn BP configured to use my ship as the Static Mesh Component

The Pawn BP has also a Camera component and it is set to follow the rotation of my pawn:

Pawn BP camera position
Pawn BP camera configured to use the Pawn Control Rotation of my pawn

The Pawn BP move forward axis event graph nodes with added reference to the ship mesh and set thrust 30:

Pawn BP move forward axis event graph nodes

Similarly the move right axis event graph is made:

Pawn BP move right axis event graph nodes

But the WASD keyboard control does not work, the ship does not move.

I tried a simple print string debug but nothing seems to come through, no messages print on screen:

Pawn BP simple print string debug attempt

I also prepared the pitch, roll and yaw. But will need to get the WASD movement to work before moving on to these:

Pawn BP pitch (LookUp) axis event graph nodes

The problem was simple. I didn't realize that to control/debug the controls in the play mode I need to click somewhere in the scene to "activate" it. After I accidentally discovered it, my flight controls worked as expected at that point. Flying forward into the sunset, showing off roll, pitch, yaw:

Flying forward into the sunset
..pitch
..roll
..yaw

3. April 18: Improved flight controls

  • The initial plane has some terrain look
  • An experimental sound added

How it went:

For better roll, pitch and yaw I changed the controls from Make Rotator and AddActorLocalRotation to Get Actor [axis] Vector and Add Torque in Degrees using also a multiplier for the torque. The torque multiplier works similar to the acceleration multiplier in the forward movement and playing with this value allows the flight to look/feel a bit more realistic.

This time the problem that prevented me to get it to work right away was the missing boolean True value for the Acceleration Change variable in Add Torque node.

Acceleration Change True in Add Torque node

The blueprints for flight controls currently look like this:

Forward movement with some debug option
Pitch
Roll
Yaw

Terrain:

At first I wanted to add a ready asset for a nice landscape but then I changed my mind and created a very simple peace of landscape myself. Just to see how it is done in principle. There was no problems but to make a really nice landscape, there are too many options to try out and it would be too long for the scope of this project. So currently this simple one stays and if in the end I want something nice, I will add a cool ready asset.

Adding landscape starts with activating the landscape edit mode.
Simple landscape sculpting.
Simple landscape painting.
Simple landscape material blueprint with layering.

Sound:

For the initial sound effect I added a custom engine sound that I made from free sound files. It starts playing automatically in Play mode. It works well and sounds nice.

Current status while flying above landscape with sound:

Flying above a primitive peace of landscape with calming low pitch engine sound

4. May 2: Smooth flight controls

  • Improved terrain has some elements added (ready made free assets, for example rocks, trees, ruins etc.)
  • If decided in checkpoint 3, one of the following made:
a) Fly the ship in 3rd person view or 1st person view (ship or cockpit - only one chosen)
b) Fly the ship with a simple switching option between the 3rd person view and 1st person view
  • 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