Smooth Flight Spaceship
Introduction
Project focus: Smooth flight controls in Unreal Engine (UE)
Project goals:
- Learn how to create a VR game scene in UE
- Learn how to use Blender model in UE
- Learn how to implement flight controls in UE
- Learn how to smooth flight controls (main target: gamepad)
- If enough time, do the same in Godot. To compare and learn. >> Not doing.
- 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
Lab4 first scene with asset:
In the first UE scene with my ship model I added one external asset pack with a customized sky.
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:
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.
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.
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.
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.
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:
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:
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:
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.
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:
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):
The Pawn BP has a Static Mesh Component and it is assigned to be my ship mesh:
The Pawn BP has also a Camera component and it is set to follow the rotation of my pawn:
The Pawn BP move forward axis event graph nodes with added reference to the ship mesh and set thrust 30:
Similarly the move right axis event graph is made:
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:
I also prepared the pitch, roll and yaw. But will need to get the WASD movement to work before moving on to these:
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:
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.
The blueprints for flight controls currently look like this:
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.
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:
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: