top of page
Search

Week 4: C++ Conversion & UI

  • Writer: Trevor Pierre
    Trevor Pierre
  • Jun 16, 2022
  • 3 min read


Last week I worked on implement the secondary flight controls as well as just generally reworking the plane pawn so that it used the Unreal Physics System. This week I planned on working on a variety of things, such as:

  • Terrain Awareness and Warning System

  • Convert Blueprints to C++

  • Basic UI

I haven’t had the chance to start on the Terrain Awareness and Warning System yet, but that’s what I plan on dedicating the rest of this week/this weekend to, since it ties in pretty closely with what I need to work on next week. But I’ll go into detail about that later in this post.


So starting from the top, I spent a good portion of my time this week converting all of the blueprints that I had made into a C++ Pawn Derived Class. But while doing so, I noticed a few things that could be improved and decided to modify so things.


One of the biggest things I noticed was how hard it was to control the plane generally using the keyboard, so I switched all the controls over so that they could be done from a controller. I’m just using a generic Xbox 360 controller, and I feel like I definitely get a lot more control with using the thumbsticks to control the roll/pitch/yaw of the plane. Below is the control scheme I have for right now:




  • Left Thumbstick Up/Down - Pitch

  • Left Thumbstick Left/Right - Yaw

  • Right Thumbstick Left/Right - Roll

  • Triggers - Throttle

  • Bumpers - Flaps

  • D-Pad Up/Down - Spoilers



Another thing that I noticed was more of a bug, that when I was rotating the plane, that the pitch would lock itself at 90 degrees and refuse to go past it. After doing some research, I learned that this was most likely Gimbals Lock.


Gimbals Lock happens with Euler Rotations/Angles, where when two axes become parallel you can lose a degree of freedom to rotate with one of those axes. Funnily enough, every visual example I’ve found of this, uses a plane as the rotating object. So here is an example of it happening with my plane:










A way to work around this is to use Quaternions. This is another rotation system that uses complex numbers. Thankfully I ran into this issue at the best time, since in Unreal, quaternions can only really be implemented using C++. On top of that, I only had to end up slightly changing my code, since Unreal supports conversions between the two systems and I was still able to interpolate between rotations.






(The jitter in this video is caused by the recording software)




As far as C++ goes, I still need to reimplement spoilers and flaps, but those are pretty trivial to do.


Moving onto the UI, right now it’s pretty simple, just listing the Angle of Attack and Altitude, but I plan on getting and displaying more data this week.




But while working with it, I found that you’re able to rotate UI objects so that should come in handy for displaying all of the Six Pack Data.


To round out this week, here’s what the current state of the plane is:





Overall this week there wasn’t a whole lot of visual change, but converting the code was a big step. Now I’m able to make children Blueprint classes based of my C++ class and work on implementing a whole bunch of new features without having to deal with the code or its clutter.

For the rest of this week I plan on reimplementing the spoilers & flaps in C++ and starting work on the Terrain Awareness and Warning System. And then next week, if everything is going according to plan, start implementing the OverSpeed and Stalling warnings, and, Traffic Collision Avoidance System.

 
 
 

Comments


bottom of page