Profile image

[SOLVED] Problem with aircraft trim

5,575 Korzalerke2147483647  1.5 years ago

The trim of the plane I'm making moves the entire horizontal stabilizers instead of just the surfaces, but the pitch control is still only done by the surfaces.

It's kinda strange being able to turn faster by using the trim (since it was only meant to stabilize level flight), so I wanted to limit it by making the surfaces move less when trim is used.

Problem is, I can't figure out how to do that, I tried subtracting the trim input from the pitch, multiplying the pitch input by lerp(1, 0.5, trim input) and even min(pitch input, trim input), but nothing works the way I want it to.

Basically, I'm trying to make it work like this:

  • Pitch works normally when Trim = 0
  • If Trim = 1, the maximum value Pitch can have is reduced to 0.5 (50%), if it's -1, same thing but negative
  • If Trim = 0.5, maximum Pitch is reduced to 0.75 (75%, basically it goes from 1 to 0.5 as Trim goes from 0 to 1)
  • If Trim = 1, only positive Pitch should be reduced, if Trim = -1, only negative Pitch should be reduced

Anyone knows a code that does that? Also sorry if this seems confusing, I'm not sure how to explain it better.

  • Log in to leave a comment
  • Profile image

    @HuskyDynamics01 Appears to work perfectly, thanks!

    1.5 years ago
  • Profile image
    1,593 XxRxX

    Over complicating the issue mate
    Just use a double spiner or whatever they called

    1.5 years ago
  • Profile image

    I'd recommend putting this in as a variable rather than directly in the control surface itself (and then set the control surface to use that variable); it's just easier that way.

    1.5 years ago
  • Profile image

    Took me a bit of trial and error, but I believe I've got something that does what you're looking for (there might be a more efficient way to do it, but this is what I could figure out).

    It'll show as multiple lines in this comment but it should all be one line when you put it in.

    (Trim != 0) ? ((Trim > 0) ? ((Pitch > 0) ? (Pitch * (1-(0.5 * abs(Trim)) ) ) : Pitch) : ((Pitch < 0) ? (Pitch * (1-(0.5 * abs(Trim)) ) ) : Pitch)) : Pitch


    Documentation for this in case you or other people want to change/improve it:

    First, checks if Trim is set. If it is greater than zero (nose down), and Pitch input is also nose down, the pitch input is multiplied by the inverse of half of the absolute value of the trim input. (For example, if Trim is -0.5 and Pitch is -1, the input to the control surface will be -0.75.) However, if there is nose-down Trim but nose-up Pitch, only the Pitch input is used.
    Same thing for nose-up Trim, just the other way around. And if there is no Trim input at all, it uses Pitch by itself.
    Or, in

    +1 1.5 years ago