Creating an Airship

After implementing my buoyancy system for my ocean I had an idea for how I could simulate hover physics to be used by a helicopter. I used to play a game called G-mod and in this game you could attach hover balls to objects in order to make them float. Using this method in a similar manner to how I implemented buoyancy to the ocean (link to buoyancy page) I could create a form hover physics that could also create create convincing procedural animations.

In the Unreal engine the amount of force natural applied to an object effected by gravity is g * mass of object. There in order to have an object floating in perfect equilibrium I need to be applying in inverse of this force. I could then split this inverse force among multiple hover points I have placed in the objects blueprint and then shift the ratio of the split force among them to make a helicopter lean dynamically. Below is an example of this with an airship I modelled in 3DS Max. I also added a ruder and fans that are controlled by my user input to add to the effect of the procedural animation.

In this video the airship has 3 hover points. 1 at the back and 2 at the front. with no input I split the inverse force as 0.5 to the back and 0.25 to each at the front, always equaling 1. Then I alter this ratio depending on the position of a virtual joystick that I move to control the airship. The reason I use a virtual joystick to control the airship instead of having the user input directly control it is because I get a more natural shift in force than I would without the joystick. Now when I want the airship to move up or down I can make the summation equal 0.9 or 1.1.

In terms of the airships AI I gave it 3 basic states. Patrol, attack, and flee. Attacking has the airship positioning its self optimally in relation to its target so that the AI for the airship guns can work optimally. The patrol state works of a reference to an array of patrol points that can allow define how the airship traverses it. In a similar way to how the user controlled airship works the AI does not control the airship but a virtual joystick that controls the airship. This makes movement more natural and even has the airship instinctively perform a 3 point turn when turning around. Below is an example of an airship in its patrol state.

The guns for the airship were also given there own AI with 5 states that are inactive, reloading, aiming, charging, and firing. The turrets also have to be able to correctly coordinate its dual rotors and be able to correctly aim it self regardless of its own orientation. In order to do this I would project the target onto the plane the each rotor operated on and depending if the value of the distance between the projected point and the target is negative or positive determines which direction I rotate in. Below is a video demonstrating the turrets ability to coordinate all these factors.

 

Code for this project can be downloading from the code listing

Advertisements