The lerk flight issue, and possible solutions.

HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
edited July 2011 in Ideas and Suggestions
<div class="IPBDescription">Enough upward force from a flap?</div>This is more of a discussion to identify the exact issue and the best solution, than it is a simple idea or suggestion (though it does have those).

I've drawn up (see below) a bunch of situations which deal with compensatory force (or lack thereof).

The idea is that for every directional flap (hold forward, press jump), you have up to three forces acting:
- your flap's <b>medial force</b> (the force that accelerates you in the forward direction),
- your body's <b>gravitational force</b> (the force that pulls you down),
- and your flap's <b>compensatory force</b> (the force that should help you maintain altitude)

<img src="http://i.imgur.com/q63SP.png" border="0" class="linked-image" />

Impulse is, in simple terms, force times time (e.g. a rocket acts with a force of 1000 Newtons for 5 seconds, so the impulse is 5000 Newton-seconds); if we hold impulse as constant, then with greater time, you'd require less force, and with less time, you'd require greater force.
Since masses are constant (and not considered by the engine IIRC), the word "force" here is analogous to "acceleration" (and "impulse" (the change in momentum) analogous to... I guess you could call it "mass-less impulse" (it's the change in velocity) - don't ask me, I only did year 12 physics).

- <b>Gravitational force</b> acts <u>over a long duration</u> - pretty much however long you are in the air; or in more relevant terms: time since your last flap, or time until your next flap.
- <b>Medial and compensatory forces</b>, however, act <u>instantly</u>.
So now you see the mismatch between gravity that gradually modifies acceleration/motion, and the other forces that act instantly to modify acceleration/motion.

I see 5 solutions to this problem, in order of difficulty:
1 - use the "jetpack" flight model (no medial impulse, instead full forward air control, limited or no left-right-or-backward air control)
2 - ignore gravity for the lerk (no need for compensatory impulse)
3 - glide is the default state (no need for compensatory impulse?)
4 - the developer arbitrarily specifies an ideal time (x seconds) between flaps, this will determine the gravitational impulse and therefore the necessary compensatory impulse. Basically, to keep your vertical motion "neutral" with respect to your forward motion (your view), you would have to flap every x seconds (this should be reasonable, and comfortable, for most players). Flap more than that, you climb with respect to your view; flap less than that, you fall with respect to your view. The problem is that: for some, it'll be too much; and for some others, it'll be too little.
5 - have compensatory impulse be some function of time (proportional). I have no idea how to begin with this.

Other possible ideas (just thought of) which may be used in combination with some of the above:
A) - With "compensation" in place, reset vertical velocity (supercompensation) with each flap to some constant, probably zero. (So it doesn't matter how fast you are falling, a flap will give you upward motion.) Two ways to do this:
A) i) -- The same for negative or positive vertical pre-velocity, e.g. zero: So, if you were falling, a flap would reset your velocity to zero, and you would fly up a little bit. However, as a result, even while flying up, your velocity would be reset, so to really climb, you would have to flap at the top of each "jump".
A) ii) -- Different cases for negative and positive vertical pre-velocity, e.g. zero when negative, and maintain the same velocity for positive: So, if you were falling, a flap would reset your velocity to zero, and you would fly up a little bit. If you were flying up, your velocity wouldn't be reset, only added to.

Comments

  • assbdaassbda Join Date: 2011-05-02 Member: 96737Members
    i like the jetpack idea thats cool.

    #1 on the list

    But should be able to go all directions
  • RokiyoRokiyo A.K.A. .::FeX::. Revenge Join Date: 2002-10-10 Member: 1471Members, Constellation
    edited July 2011
    <i>EDIT: Nevermind...</i>
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    @Harimau: Sorry I didn't read your entire post.

    Actually, the Lerk currently ignores gravity as long as it is "gliding", on the condition that the Lerk is facing in the general direction of its current flight velocity. If the Lerk turns too quickly, it would stop "gliding" and start to fall due to gravity.
  • HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
    edited July 2011
    "If the Lerk turns too quickly, it would stop "gliding" and start to fall due to gravity."
    Hmm, that sounds fairly clumsy, and isn't really... clear to the player.

    And also, this thread has more to do with free flight - I haven't really touched on gliding (I consider them two complementary, but essentially separate, flight models - gliding mostly works).

    I don't really like <!--coloro:#9999FF--><span style="color:#9999FF"><!--/coloro-->#1<!--colorc--></span><!--/colorc--> because... well... that's what I want the jetpack to be. It is obviously the easiest flight model available though (to use as well as implement).
    <!--coloro:#00FF00--><span style="color:#00FF00"><!--/coloro-->I personally think that the lerk should move in three dimensions with greater freedom - all tied to his view direction (the direction he is looking is the absolute direction he should be moving).<!--colorc--></span><!--/colorc-->
    The jetpack model on the other hand is kind of restrictive - essentially you're jumping (flap gives upward vertical acceleration only, like a jump), but moving left/right/forward/backward is the same with respect to the ground plane as walking (although, as a winged creature, it wouldn't make a lot of sense to have it move too much left or right or backward).
    However, the obvious difference that I see between the marine jetpack model and the "lerk jetpack" model, is that the lerk uses discrete flaps (tapping spacebar) to provide instant impulse (change in velocity) while the jetpack would have more gradual acceleration (holding spacebar). The lerk also still has the ability to glide, and would more likely move forward much faster than a jetpack marine would.
    The biggest difference between the "lerk jetpack" and the current model is that the "lerk jetpack" has no medial impulse, and you move parallel with the ground using arrow-keys without even flapping (flapping just takes you up).
    <!--coloro:#9999FF--><span style="color:#9999FF"><!--/coloro-->-> A single jump to get off the ground, then further jumps would take you further up, regardless of what direction you are facing (your view) or what directional key you are pressing. Holding the forward directional key will make you move forward, regardless of the pitch of your view. Backward key probably does nothing during flight. Left/Right keys allow you to strafe to some extent.<!--colorc--></span><!--/colorc-->

    Regarding <!--coloro:#FF9999--><span style="color:#FF9999"><!--/coloro-->#3<!--colorc--></span><!--/colorc-->, I think it would be quite interesting to have glide as the default state (I mean, it's the default state in bird flight...); that is, you don't have to hold "Jump" to glide. On the other hand, you could have "Crouch" as the don't-glide "special case" button (basically we have a reversal of the current situation where glide was the special case). What this would mean is that flaps would mostly be used in edge cases - higher intensity situations. Like, for example, a very quick change in direction, or needing to fly straight up, or modifying your velocity (forward+jump to increase velocity, backward+jump to decrease velocity). I'd remove the passive gliding acceleration bonus over time though, and have it only be modified by your flaps.
    <!--coloro:#FF9999--><span style="color:#FF9999"><!--/coloro-->-> A single jump to get off the ground, then a second forward+jump to begin gliding slowly. More standard jumps to move straight up. More forward+jumps to increase forward velocity. Backward+jump to decrease forward velocity, or move backward slightly if your velocity is zero, but the backward motion is not sustained (it decelerates to zero, so you need to keep flapping to sustain it). Left/right+jump to move left/right slightly, whatever your velocity, but the lateral motion is not sustained (it decelerates to zero, so you need to keep flapping to sustain it).<!--colorc--></span><!--/colorc-->

    Regarding <!--coloro:#99FF99--><span style="color:#99FF99"><!--/coloro-->#5<!--colorc--></span><!--/colorc-->, I had an idea where... the time since the last flap determines the magnitude of the compensatory force.
    <strike>For example, if the longest ideal time between flaps to sustain your flight was <b>1.2</b> seconds (a flap takes you up for <b>0.6</b> seconds, and then you fall the same distance for <b>0.6 seconds</b>)... Basically, if you were facing in a certain direction, and flapped once every <b>1.2</b> seconds, overall you would basically follow that direction in a straight line. Let <b>g</b> = 9.8 = acceleration due to gravity. Let <b>t</b> = time since the last flap.
    Then have a clamp:
    <!--coloro:gray--><span style="color:gray"><!--/coloro-->If t > <b>0.6</b> <!--colorc--></span><!--/colorc--> (falling)
    <!--coloro:gray--><span style="color:gray"><!--/coloro-->Upward Compensatory Force (change in velocity) = Clamp(0, <u>2*<b>g</b>*<b>t</b></u>, 2*<b>g</b>*<b>1.2</b>)<!--colorc--></span><!--/colorc--> ; if I've got my maths/physics right anyway.</strike>
    <!--coloro:#999999--><span style="color:#999999"><!--/coloro--><i>Not really working... but the idea is to have it so that the extra distance fallen since last flap = compensated distance risen with new flap, and this is basically done by reversing the falling velocity (a "bounce") gained by gravity in the time since the last flap.</i><!--colorc--></span><!--/colorc-->
    <!--coloro:#99FF99--><span style="color:#99FF99"><!--/coloro-->-> If you forward-flap every 1.2 seconds, you will move in a straight line; this is useful when you're just cruising. If you forward-flap more frequently (i.e. gravity has had less time to act on you) than every 1.2 seconds, you should still move in a straight line rather than move up because the <u>middle value</u> accounts for that; this is useful when you want to take advantage of the acceleration from the medial force. If you forward-flap less frequently than every 1.2 seconds (since the upward force is capped at 1.2 seconds) you will begin to drop, since the compensatory force is not adequate to keep you moving in a straight line; this is useful when you want to, well, drop.<!--colorc--></span><!--/colorc-->
  • HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
    edited July 2011
    <!--coloro:#99FF99--><span style="color:#99FF99"><!--/coloro-->#5<!--colorc--></span><!--/colorc-->, revisited (I just can't let this go)
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// default u = - gT

    // T = arbitrary maximum time since last flap to "bounce" back up to the maximum height.
    // g = acceleration due to gravity (up is positive, so g is negative)
    // u = velocity at time of previous flap
    // t = time since last flap
    // v = current velocity [intermediate]
    // u' = new velocity at time of flap [intermediate]
    // comp = change in velocity (compensation) to "bounce" back up

    // if (v = (u + gt)) >= 0 (rising or level)
    // do not reverse falling: u' = v = u + gt
    // comp = u' - v = v - v = 0

    // elseif (v = (u + gt)) < 0 (falling)
    // reverse falling: u' = -v = -(u + gt)
    // comp = u' - v = -v - v = -2v = -2(u + gt)
    // u = u + comp

    // SO:

    u = -g*T    // set default
    if (u+g*t) >= 0    // rising with respect to the view
    then    comp = 0
    elseif (u+g*t) < 0    // falling with respect to the view
    then    comp = -2*(u+g*Clamp(0,t,T))    // reverse falling velocity, for maximum time of T seconds
    end
    u = u + comp<!--c2--></div><!--ec2-->
  • wulf 21wulf 21 Join Date: 2011-05-03 Member: 96875Members
    <!--quoteo(post=1859456:date=Jul 10 2011, 06:18 PM:name=Harimau)--><div class='quotetop'>QUOTE (Harimau @ Jul 10 2011, 06:18 PM) <a href="index.php?act=findpost&pid=1859456"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I think it would be quite interesting to have glide as the default state (I mean, it's the default state in bird flight...); that is, you don't have to hold "Jump" to glide. On the other hand, you could have "Crouch" as the don't-glide "special case" button (basically we have a reversal of the current situation where glide was the special case).<!--QuoteEnd--></div><!--QuoteEEnd-->

    Actually we currently have 3 states. Not holding jump makes you slowly go to the ground, holding crouch enteres free fall.
  • HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
    Ah, that's right. Gravity is reduced when flying as a lerk. An odd way of doing things, but I guess if it works...
  • Taxen0Taxen0 Join Date: 2010-07-30 Member: 73357Members
    I took some time to learn the new lerk, and to my surprise it actually works pretty good.
    I would like to see a removal of slow on hit for the lerk, and so that you don't lose altitude when strafing and flapping at the same time.
Sign In or Register to comment.