Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2062 closed enhancement (fixed)

[PATCH] Landing and Go-Around for Flying Units

Reported by: scythetwirler Owned by: peter
Priority: Nice to Have Milestone: Alpha 14
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by scythetwirler)

I've implemented landing and a go around function for (mostly) the P-51 Mustang. The land command is issued using the stop button and to go around, simply press the stop button again (to abort the landing).

I've also adjusted a couple speeds on the Mustang.

Attachments (3)

landingFlyingUnits.diff (7.9 KB ) - added by scythetwirler 11 years ago.
watersink.patch (6.2 KB ) - added by scythetwirler 11 years ago.
watersink.2.patch (7.5 KB ) - added by scythetwirler 11 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 by scythetwirler, 11 years ago

Description: modified (diff)

comment:2 by alpha123, 11 years ago

Functionality-wise, this works quite well and looks really cool. I'm having some trouble landing the planes however, and I saw one go underwater briefly. I unfortunately don't have more time to test this currently, but I'll get back to it.

Code-wise I have a few problems, mostly relating to coding style:

  • There's a lot of duplication between UnitFlyingMotion.js lines 70-83 and 90-100. I suggest lifting the common parts out of the conditional.
  • You left an extra blank line at plane.xml line 46.
  • I suggest renaming this.touchdown to this.onGround or similar, IMO it is more descriptive that way. I was initially slightly confused whether touchdown meant that it was in the process of landing or was already on the ground. That would also remove the need for the redundant comment on UnitFlyingMotion line 45.
  • You have inconsistent operator spacing; on line 142 you use spaces around the multiplication operator but no where else. I suggest spaces everywhere.
  • However on line 142 you don't put spaces around your subtraction or division operators - in general you want spaces around every operator.
  • You have a pair of superfluous parenthesis on line 94. You could argue that these make it easier to read but I think they look weird.
  • There is an unnecessary and inconsistent pair of brackets on lines 148 and 150.

by scythetwirler, 11 years ago

Attachment: landingFlyingUnits.diff added

comment:3 by scythetwirler, 11 years ago

Thanks for the great review! :) I've fixed all of them except your 6th bullet. Removing the parenthesis seems to make it function differently.

Also, the GetGroundLevel() function seems to always detect terrain, ignoring water levels. I'm not sure how to resolve this.

Last edited 11 years ago by scythetwirler (previous) (diff)

comment:4 by peter, 11 years ago

Owner: set to peter
Resolution: fixed
Status: newclosed

In 13658:

Implement landing and go-around for UnitMotionFlying. Patch by scythetwirler. Fixes #2062.

comment:5 by sanderd17, 11 years ago

In 13660:

interpollate y offset for smooth climbing and landing of flying objects. refs #2062

comment:6 by sanderd17, 11 years ago

Keywords: review removed

Ah, thanks, nice patch.

I didn't like the "steps" a plane took when it was climbing or landing. So I implemented some interpolation. Now it climbs smoothly.

If you want to research the angle a plane has when landing or climbing, you can implement that too. Just with the SetRotation method. X is sideways rotation (aka roll) so you don't need this (= always 0), but Z is forward/backward rotation (aka pitch), this is the one you need. Normally, the rotation would already be smooth. You can also put those angles in the XML, as it will probably differ by plane type.

One remark on the code: If you have a block like

if (!condition)
    CODE BLOK 1
else
    CODE BLOK 2

it's better to turn it around for readability

if (condition)
    CODE BLOK 2
else
    CODE BLOK 1

the only reason to use if (!condition) is if you don't have an else block. As the patch is already in, I won't change it, just remember it for the next time.

Last edited 11 years ago by sanderd17 (previous) (diff)

comment:7 by sanderd17, 11 years ago

In 13661:

fix tests breaking caused by r13660. Refs #2062

comment:8 by sanderd17, 11 years ago

And of course I had to break the tests. Anyway, it works now.

comment:9 by sanderd17, 11 years ago

There is one rather annoying problem with the patch though. When you land your planes next to the edge of the map, you can lose some planes

It would be nice if, after landing, you can check if the planes are on the map, and if they aren't, move them to the map (riding is enough, don't have to fly).

by scythetwirler, 11 years ago

Attachment: watersink.patch added

comment:10 by scythetwirler, 11 years ago

Thanks sanderd17! I've reversed the if else code.

New patch fixes planes landing below the surface of the water.

comment:11 by scythetwirler, 11 years ago

Resolution: fixed
Status: closedreopened

comment:12 by scythetwirler, 11 years ago

Keywords: review added

by scythetwirler, 11 years ago

Attachment: watersink.2.patch added

comment:13 by scythetwirler, 11 years ago

Resolution: fixed
Status: reopenedclosed

comment:14 by scythetwirler, 11 years ago

Really does deserve its own ticket. #2067

comment:15 by leper, 11 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.