251
edits
Icecream17 (talk | contribs) (fix misinformation) |
Icecream17 (talk | contribs) (→update_flying: explain best flying) |
||
(One intermediate revision by the same user not shown) | |||
Line 56: | Line 56: | ||
Notice that there is no code handling air steps for ledge grabbing or hanging on a ceiling, so such transitions are impossible. | Notice that there is no code handling air steps for ledge grabbing or hanging on a ceiling, so such transitions are impossible. | ||
===update_flying=== | ===update_flying=== | ||
Casually, tilt the joystick left to move left, right to move right, up to move down, down to move up. | Casually, tilt the joystick left to move left, right to move right, up to move down, down to move up. '''TODO:''' I heard moving down then up can be faster then just the direct line. Explain big picture movements, what happens in a practical example. | ||
Beyond this, the pseudocode is provided but probably isn't as useful as the <code>update_flying</code> code itself: | |||
# Joystick inputs affect (pitch,yaw) velocity. | |||
# Yaw velocity affects yaw, roll, and forward velocity. | |||
# Pitch affects forward velocity. | |||
# Forward velocity becomes at least 0 | |||
# Forward velocity affects pitch (see below table) | |||
# Pitch velocity affects pitch. | |||
# Pitch is clamped to be inside [-0x2AAA, 0x2AAA] | |||
# x,y,z velocity is more or less directly exactly trigonometrically correspondent to forward velocity, pitch, and yaw. | |||
# xz sliding velocity updated to correspond | |||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
void update_flying(struct MarioState *m) { | void update_flying(struct MarioState *m) { | ||
Line 99: | Line 108: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Key takeaways''': | '''Key takeaways''': | ||
* Pitch velocity ''additively'' affects forward velocity, but ''sin'' effects pitch. '''The most energy efficient flying is to fly a lot down, and then a little up''', as, for example, sin(-0.5) + sin(0.25) + sin(0.25) ≈ 0.0153823799048 (positive), while the totally additive effect is still 0 (actually -0.3 because of a flat -0.1 per trame) | |||
* Pitching to move up happens faster with higher forward velocity. | * Pitching to move up happens faster with higher forward velocity. | ||
** The difference between 4 and 5 speed, and 16 and 17 speed is especially large. | ** The difference between 4 and 5 speed, and 16 and 17 speed is especially large. | ||
Line 106: | Line 116: | ||
* Pitch has a minimum and maximum and cannot overflow with standard speeds. | * Pitch has a minimum and maximum and cannot overflow with standard speeds. | ||
* '''More below the tables''' | * '''More below the tables''' | ||
{| class="wikitable" | {| class="wikitable" | ||
|+forwardVel's affect on pitch | |+forwardVel's affect on pitch | ||
Line 151: | Line 160: | ||
|6 | |6 | ||
|} | |} | ||
<hr> | <hr> | ||
Here are some tables summarizing the <code>approach_s32</code>, <code>update_flying_pitch</code>, and <code>update_flying_yaw</code> functions. | Here are some tables summarizing the <code>approach_s32</code>, <code>update_flying_pitch</code>, and <code>update_flying_yaw</code> functions. | ||
Line 224: | Line 220: | ||
#Add yaw velocity to yaw | #Add yaw velocity to yaw | ||
# Set roll to yaw times negative twenty (-20) | # Set roll to yaw times negative twenty (-20) | ||
'''Note that turning left = positive yaw''' (up = positive pitch).<ref>https://youtu.be/TQt8MCsniQI</ref> | '''Note that turning left = positive yaw''' (up = positive pitch).<ref>https://youtu.be/TQt8MCsniQI</ref><syntaxhighlight lang="c"> | ||
<syntaxhighlight lang="c"> | |||
/** | /** | ||
* Return the value 'current' after it tries to approach target, going up at | * Return the value 'current' after it tries to approach target, going up at |
edits