Plane Banking and Torpedoes
I made an attempt to do quite a bit of work today which unfortunately didn’t entirely end up working as planned, although I did get quite a bit done anyway. After some rather strenuous work figuring out at least partially how to get Quaternions and Euler angles working only to end up not using either mathematical functions to make planes turn more realistically I got it working to some extent. Although there is still the issue of planes occasionally crashing into the rocks, island or doing its own stunts, they turn.
The method I’ve used isn’t exactly the right way, but somehow from a combination of guess work it does appear to correctly turn most of the time. I did a few trials and haven’t found too many problems with it. It works by subtracting the old Y-direction (Along the horizon in Unity) from its current one every frame, multiplying this by a massive 8000, then multiplaying again by the time multiplier (for smooth movement regardless of FPS) and somehow this works. To be perfectly honest, I don’t even know how, but eh..
As for torpedo bombers, those work now too. All boats are able to detect the torpedoes and their guns can be blown off too. Unfortunately in the example screenshots below this didn’t really happen as the torpedo was probably too low, and blew up too far away. This will be fixed with a larger detection radius.
Next up are the fighter planes, probably the most difficult and messiest of them all as I have to make sure of a lot of things here.
- They don’t go kamikaze-style flying into the enemy planes.
- They stick to a single target.
- They don’t just randomly crash into the sea or land.
Unfortunately for me I am yet to figure out all three of these little issues but I’ve gotten this far already.