WWII Aircraft Flight Dynamics - Demo for feedback

Hi everyone. This is a WWII aircraft (F4F Wildcat) Grumman F4F Wildcat - Wikipedia . I’m working on getting a decent flying experience down at first. I’m not shooting for pure simulation. I want an arcade feel with a touch of realism on the flight characteristics. Right now all of the GUI stuff is a temporary readout for me to see values I need to remember to plug into proper UI elements later on. I’m actually trying to get an incremented engine power going, but having issues at the moment. Right now it just powers forward if you hold the button down I would rather it be more of a power level thing, where you tap the + button or something and the engine goes up by 10% and vice versa with using the - button or something (drop in engine power 10%).

The controls are WASD for flight controls, SpaceBar to fire the guns, “>” key for engine power, “<” key for brakes.

I will take any and all feedback on it. I’m especially seeking help in the best keys for the controls (what feels most comfortable for most people)…and of course incremental engine power functionality.

Link to the webplayer: http://dl.dropbox.com/u/16956434/FlightProject/WebPlayer.html

The roll rate is way to low.

The direction the ailerons and elevator goes are flipped - in real life they would go in the opposite direction - steering of an aircraft works by increasing/decreasing lift of a lifting surface, the chamber of the airfoil will be increased (and so the lift) when the aileron or elevator goes down and decreased when it goes up.

Also your arcade fm needs to simulate the effect of the stabilizers.

Rudder is completely missing.

If you can spare a few bucks (<$10), you could buy IL-2 Sturmovik 1946 (includes the F4F as well). Just to play around with it and get a feel of how the aircraft react in that game, they aim for realism but have a bunch of settings to tone it down to a more arcady feel as well. If you are into flight sims it’s definitely worth its money.

I’ll give your demo a try as soon as I’m back from work.

@VIC20 - Yeah I’ve fixed the inverted control surfaces. I haven’t put an animation in for the rear rudder yet, so I know that’s not moving. I agree the roll rate needs to be upped…it’s a simple variable multiplier in the inspector. When you said “Also your arcade fm needs to simulate the effect of the stabilizers.” Does that mean some additional forces I’m not seeing on the aircraft? Like sideways force or something?

@Ramsar - I’m going to give that a look and potentially a purchase. I’ve played quite a bit of Microsoft Combat Flight Simulator and Century of Flight but it’s been a long while. I’ll have to break out that yoke stick again :). Actually this game has had my interest piqued as well… http://damageincthegame.com/

An aircraft stabilizer may provide longitudinal (or pitch) stability, or directional (or yaw) stability. A longitudinal stabilizer is a surface that provides forces that tend to keep an aircraft flying level and with unchanging “pitch” angles relative to the airstream; the nose of aircraft is prevented from pitching up or down. A directional stabilizer tends to keep the aircraft flying straight ahead with unchanging direction relative to the airstream (yaw stabilization). Static vertical stabilizers are small wing surfaces placed behind the center of mass of an aircraft, either as part of the tail empennage or outboard on aft-swept wings. A static horizontal stabilizer may be placed either behind the center of mass, as a tailplane, or forward of it as a canard foreplane (wikipedia)

A video showing forces on the aircraft in my own flight dynamics model:

Explanation of the visualizer:

  • when lines are turned on: shows force of lift
  • when the primitive 3D model is turned on: the more red the wing sections are the higher the drag

At 40 seconds you can clearly see the directional stabilizer in action (no visualized forces)
At 01:16 you can clearly see the longitudinal stabilizer in action.
At 5:56 you can again clearly see the directional stabilizer in action, this time visualized forces are on

BTW: basically the plane in this video just flies like it does because

  • of its basic shape (airfoil data of the relevant wing sections)
  • resulting changes to the chamber of the airfoils due to ailerons and elevator
  • thrust of the primitive simulated engine.
    No tweaks are necessary

https://www.youtube.com/watch?v=Z-_yhdGtbRk

Wow that is awesome! I do have a variable for adjusting the “level flight” ratio…I think this will help me get started. That was another set of forces I really toned down in the settings. I’m going to have to take a second hard look at the settings.

I have a need for some assistance from anyone knowledgeable in scripting animations. This is the script controlling animations on the aircraft.

var planeWithAnimations : GameObject;

function Start () {
	planeWithAnimations.animation["idle"].wrapMode = WrapMode.Loop;
	planeWithAnimations.animation["turnright"].wrapMode = WrapMode.ClampForever;	
	planeWithAnimations.animation["turnleft"].wrapMode = WrapMode.ClampForever;
	planeWithAnimations.animation["elevatorup"].wrapMode = WrapMode.ClampForever;
	planeWithAnimations.animation["elevatordown"].wrapMode = WrapMode.ClampForever;
	planeWithAnimations.animation["yawleft"].wrapMode = WrapMode.ClampForever;
	planeWithAnimations.animation["yawright"].wrapMode = WrapMode.ClampForever;
	
	planeWithAnimations.animation["idle"].speed=2;
	planeWithAnimations.animation["turnright"].speed = 2;	
	planeWithAnimations.animation["turnleft"].speed = 2;
	planeWithAnimations.animation["elevatorup"].speed = 2;
	planeWithAnimations.animation["elevatordown"].speed = 2;
	planeWithAnimations.animation["yawleft"].speed = 2;
	planeWithAnimations.animation["yawright"].speed = 2;

}

function Update () {

		if (Input.GetKey (KeyCode.D))
    {
    	planeWithAnimations.animation.CrossFade("turnright");
	}
		else if (Input.GetKey (KeyCode.A))
    {
    	planeWithAnimations.animation.CrossFade("turnleft");
	}
		else if (Input.GetKey (KeyCode.W))
    {
    	planeWithAnimations.animation.CrossFade("elevatorup");
	}
		else if (Input.GetKey (KeyCode.S))
    {
    	planeWithAnimations.animation.CrossFade("elevatordown");
	}
	else if (Input.GetKey (KeyCode.M))
    {
    	planeWithAnimations.animation.CrossFade("yawright");
	}
	else if (Input.GetKey (KeyCode.N))
    {
    	planeWithAnimations.animation.CrossFade("yawleft");
	}
		else
	{
		planeWithAnimations.animation.CrossFade("idle");
	}
}

So they all do play as expected…everything also reverts back to the idle animation state if no buttons are being pressed. My issue is coming from when I am depressing more than one button, say I’m holding the A Key down to do a hard bank left and then I hit the N Key to yaw left as well…well the rear rudder (yawleft) animation gets kind of stuck and won’t come out of it’s animation if I’m hitting the D Key to turn right. It appears when using multiple keys one or the other of the animations get’s stuck or resets to frame 1 of that animation. I.e. when I let up the turning left button, the rear elevator animation will be stuck in it’s last frame until all of the buttons are let up and it returns to idle.

I’m also having another issue of all of the other animations affecting my gear down animation. This is the animation that lowers the landing gear. It’s also affecting the same animation as it plays in reverse to bring the gear back up. Here is the script for the landing gear. I separated it into it’s own script thinking that would allow me to kind of separate the landing gear animations. It feels like the landing gear animation is trying the “blend” or crossfade with the other animations. It will play fine if no other buttons are depressed…but the issue occurs when other buttons are depressed during that animations playback. Any and all help will be greatly appreciated. I’m giving this project to the community for free once it’s completed and I want it working as good as it can be.

Here is this script.

#pragma strict
var planeWithAnimations : GameObject;

function Start () {
	planeWithAnimations.animation["idle"].wrapMode = WrapMode.Once;
	planeWithAnimations.animation["landingGearUp"].speed = 1;
	planeWithAnimations.animation["landingGearUp"].layer = 1;
}

function Update () {

		if (Input.GetKeyUp("g"))
    {
    	planeWithAnimations.animation.CrossFade("landingGearUp");
    	planeWithAnimations.animation["landingGearUp"].speed = 1;
	}
		else if (Input.GetKeyUp("h"))
    {
    	planeWithAnimations.animation.CrossFade("landingGearUp");
    	planeWithAnimations.animation["landingGearUp"].speed = -1;
	}
}

Just tried out your demo and…

  • Boy that F4F is packing a mighty engine :wink: Going vertical and almost no loss in speed, it just keeps climbing.
  • Flying inverted doesn’t feel right either, it just flies along happily in a straight line.
  • Furthermore, I’m definitely missing rudder controls.
  • You can taxi backwards if you press the decrease engine power button while standing still
  • Aircraft behaves the same in all speed conditions

But whether or not you should be concerned about these remarks totally depends on the degree of realism you want to achieve. However, to be honest (if I may) the flight model you have now is full arcade. How are you programming your flight behaviour, through a flight dynamics simulation (like the demo of VIC20) on the aircraft or just all pre-programmed behaviours?

I’m not an expert in flight dynamics. Although you should make it possible to stall the aircraft. When I played the demo I tried stalling by going completely straight up, but I couldn’t. A lot of other Unity aircraft controls are missing this. If you remember to implement this one thing it would make it 10 times better than the rest.

Also if the player rolls the aircraft to its side 180 degrees, it should have a tendency to head toward the ground if the player does not compensate for it.

Lastly, there should be a smoothing script on the camera so its not so fixed on the aircraft. I have a script that will do this if you want.

For your problems with the animations, if you dont know already I believe you need to isolate bones to certain animations so they dont effect other parts of the bone hierarchy with addMixingTransforms. Take a look at this.

file:///C:/Program%20Files%20(x86)/Unity/Editor/Data/Documentation/Documentation/ScriptReference/AnimationState.AddMixingTransform.html

Roger, you actually just gave me an idea for the way to tackle the animation issue. I can just export out the landing gear as its own model and manually place it into the plane’s heirarchy! This way its completely isolated from the rest of the model. You guts have given great feedback on the issues I need to tackle. I’m seeing the common themes with the things I need to fix.

Okay finally! So I’ve got the animations playing for the landing gear unobstructed…they go up and they come down. I exported out with the anims set to ClampForever, so they don’t trigger right at the moment (sometimes gotta hit the key twice). That’s an easy fix. I’ve now got to tackle some of the physics issues and would like to see stalling happen.

Link to the webplayer: http://dl.dropbox.com/u/16956434/Fli...WebPlayer.html

The new additional controls for the landing gear: G to raise the gear, H to drop it back down.

The controls are WASD for flight controls, SpaceBar to fire the guns, “>” key for engine power, “<” key for brakes.

The cool thing is the landing gear wheels now have the wheelColliders parented under their hierarchy, so the wheelColliders tuck up away like they should (no need to even disable them). I’m considering removing the ability to put the gear up while on the ground. It’s not a tough implementation considering I’m getting the wheel hit data from the wheelColliders to determine if the plane is on the ground.

I wouldn’t do that :slight_smile: In reality it’s a possibility as well and it’s a funny mistake to make as a player. Once you’ve made it, you’ve learned your lesson…

Updated webplayer : http://dl.dropbox.com/u/16956434/FlightProject/WebPlayer.html

As you can see I’m working on a night time area type of environment. Almost ready to call this one done and put the project up on the site for free download.

Its a big improvement over last time. Although if I were you I wouldn’t finish it quite yet. Its great that the airplane can stall now when going up. And that it looses lift if flying sideways.

  1. I noticed when flying toward the moon, the airplane has a tendency to go down if not compensated for, but while flying the opposite way of the moon, the plane has a tendency to go up! This is really strange.

  2. At the beginning when your on the ground, if the player does nothing at all, the plane will flip over eventually. I’m guessing this is due to the same force being applied to the plane to make it have a tendency to go down/up automatically during flight. You should check if the player is off the ground before applying this force. (Also i’m wondering why the force exist in the first place, its kind of annoying to have to compensate for it although it might be a flight dynamic i’m not aware of).

  3. The flaps, rudder, and tail wings still have animation issues. When pressing down on multiple inputs, the animations get a little confused it seems. Like if you roll and go up at the same time the flaps animation will play again or vise versa. My advice would be to just separate all of the moving parts into different gameObjects. You wont have to worry about AddMixingTransforms or anything and it seems like it would be more simple to deal with. Plus if the controller requires animations then whoever is using the tool would have to make their own animations for their aircraft in another program, rather than just separating the moving parts into different layers.

  4. The sound controller for the engine has not really been worked on. If would be nice if the pitch for the engine changes depending on how fast the player sets it to. I would suggest making a sound controller where the user can get a custom sound effect of a engine and plug it into a variable and have the pitch change accordingly.

You should try selling this in the asset store instead. If you keep working on it and fixing the problems then it will probably be the best flight controller for Unity that someone can buy. I wouldn’t mind paying 70.00 or so for it. Also are you going to make it compatible for joysticks?

To be honest: the first line of the quote seems to be true. I’ve worked a lot on flight controllers and so far I’ve played flight sims for more than 10,000 hours (this is just a low level of being addicted :smile: ) - sometimes even those with “easy mode”.

I would call this a first test of something that could end as an arcade flight controller someday, but it is really far away from being finished. I suggest to download some flight sim, fly around and watch the important behaviors of the aircraft (also release the stick in different flight conditions) - then think about how to simplify these behaviors to make it even easier to control the aircraft. Basically aircrafts are easy to control. But with your approach it is actually harder to control the aircraft because it does not act like an aircraft at all. All those work on animations is not important as long as the basic arcade-simulation of the aircraft is unfinished.

Good work buddy.

Yeah. I agree. This is not a game or for any commercial purpose…it was something to bundle up and give away to folks for free. I think it’s just getting overly complex for my tastes and I’d rather divert my resources elsewhere. I’m gonna fix it up a bit, try to improve the glaring issues with it and put up the free downloadable archive on my site. I’m going to put my implementation of mobile ocean water, add in GUI joystick control for mobile and be done with it. Thank you guys for the input and feedback.