Profile image

[yapping] animation approach to landing gear

113k hpgbproductions  3 days ago

You don't have to mess with smooth - or to be more accurate, you only have to use it once in a very simple way, which avoids the pitfalls of trying to combine it with branches (they do not update if their branch is not taken).

Use smooth to make an animator variable (timer) that goes from 0% to 100%. It will be 0% when the landing gear is fully extended, and 100% when the landing gear is fully retracted. You can do it as either:

  • Progress basis: smooth(GearDown ? 0 : 1, PROGRESS_RATE), or
  • Time basis: smooth(GearDown ? 0 : MAX_TIME, 1)

For each rotator, piston, etc., plot a series of lines and curves of the state of the part over time, taking note of the domain of each line or curve.

  • For lines, you can use the linear mapping formula lerp(y1, y2, inverselerp(x1, x2, x)), which converts the value x in the range x1..x2 to the appropriate value in the range y1..y2. Also try smoothstep in place of lerp.
  • For curves, you will need to use graphing software.

Then, you can use a ternary operator chain to choose the correct line or curve to use:
ANIM<T1 ? C1 : (ANIM<T2 ? C2 : (...))

So how do you actually apply this in construction?

  1. Identify the components of the gear leg/door system, that you want to move independently of each other.

    • Also identify which states (opened/closed) correspond to which input values.

  2. Plan what movements the gear leg/door system will make, e.g.,

    • Does it start as 0 or 1?

    • Does it make one or two movements, or more?

    • Does it wait before moving?

  3. Design curves, with rough timing values, matching the movement patterns you decided.
  4. Implement the curves and check motion.
  5. Adjust timings and repeat (4) until you are satisfied with the animation.
  • Log in to leave a comment
  • Profile image
    41.3k Graingy

    Oh. Being pedantic, FT is a programming language. The number of interactable programs people have made backs that up.
    Maybe you should clarify how you format so people don't come in and be confused, chasing around some nonexistent variable or function they thought they missed.

    yesterday
  • Profile image

    @Graingy The constants thing comes from actual programming languages, not FT. I use the same style to show that players must replace it with a number.
    .
    Sorry for the accidental misinformation

    yesterday
  • Profile image
    41.3k Graingy

    I see? Never saw that in the guide, though from what I've gathered it's highly incomplete.

    yesterday
  • Profile image

    @Graingy i follow the programming standards, where names in all caps are constants

    yesterday
  • Profile image
    41.3k Graingy

    Hm.
    As for the code in the post, are things like MAX_TIME actual FT components, or just how you write placeholders? They don't seem familiar to me.
    I'm confused how this entire thing is distinct from using using ceil and... whatever the opposite one was.

    yesterday
  • Profile image

    @Graingy a compound curve of straight lines looks like this
    Red is MainGearLeg, blue is MainGearDoor. However, you should not program using normal linear equations in real FT because it is unreadable

    yesterday
  • Profile image
    41.3k Graingy

    I am not at all following any of this. Text instructions are difficult to parse for such a thing.

    yesterday
  • Profile image

    @Graingy plot the points of position (y-axis) over the animator (x-axis), and make your lines/curves from there
    Personally, the few times I have done this, I never used curves, only straight lines

    2 days ago
  • Profile image
    41.3k Graingy

    I more meant this graphing thing you talked about.

    2 days ago
  • Profile image

    @Graingy
    I found one that I've used before. It's only a main landing gear with a single door, but the gear movement is offset slightly to prevent touching the door.
    Timer: smooth(GearDown?0:10,1)
    MainGearLeg: lerp(0, 1, inverselerp(0, 9, Timer)) where 0 is retracted
    MainGearDoor: lerp(1, 0, inverselerp(5, 10, Timer)) where 1 is open

    2 days ago
  • Profile image
    41.3k Graingy

    Jokes aside, would it be possible to see an example of what this would look like?

    3 days ago
  • Profile image
    41.3k Graingy

    The doohickeys are operating at peak efficiency

    +1 3 days ago
  • Profile image
    52.6k ShinyGemsBro

    Hm yes the numbers are numbering and the code is coding
    .
    As planned

    3 days ago
  • Profile image

    @YarisHatchback you can make any animation in the simple with this

    3 days ago
  • Profile image
    50.7k PlaneFlightX

    Very interesting. My landing gear code all uses the same smooth() timer, although it's more linear, with simple code (no ternary operators) to do things like open the gear doors in the first 1 second, and retract the gear for the next 8 seconds, followed by gear doors closing for the last second.

    3 days ago
  • Profile image

    awwww man i thought it was going to be a tutorial on animation :(((((((

    3 days ago