Fly navigation like in the editor in application

Hello, is there any class, or specific setting for WalkNavigation to force it to behave like the fly navigation in the view3dscene tools or in the editor? I tried to create WalkNavigation, assign it to viewport and set the gravity to false, but I am not able to replicate exact same behavior of movement as in the editor e.g. (which would be desirable). Thanks for any advice.

Both view3dscene and CGE editor use exactly the TCastleWalkNavigation class, no cheating :slight_smile: So you should absolutely be able to get 100% the same behavior in your own applications by using TCastleWalkNavigation.

You can take a look at this file:

It defines TCastleWalkNavigationDesign that is used by CGE editor, it is a descendant of TCastleWalkNavigation. You should be able to do something similar (or simpler, depending on your needs) in your application.

Well, basically I did not want to spend much time on creating custom navigation, and fly like nav in view3dscene and editor is pretty much what I need, thats why I ask if there is any of those types available within sources, I was not able to find this somehow, thanks. But just one thing, I tried to duplicate it exactly like here, mouse look works fine, but is there a need to set up something else to be able to also move with W, A, S, D, Q, E? Because that does not work, so not sure if thats implemented like somewhere else, or if I just need to set some field correctly to be able to move around. Thanks.

The AWSD keys should be automatically supported by the TCastleWalkNavigation .

See https://github.com/castle-engine/castle-engine/blob/master/src/transform/castlecameras.pas#L2906 for standard keys set up by the TCastleWalkNavigation .

You can always assign/change them manually too, by a line like MyWalkNavigation.Input_Jump.Assign(keyQ). (As it happens, Input_Jump is a bit special: it is for jumping when Gravity=true, or for flying up when Gravity=false. Similar for Input_Crouch.)

That said, from your other thread ( Antialiasing in TCastleControl on Delphi VCL Form? - #2 by michalis ) I guessed you may be using TCastleControl with VCL (in the context of this thread). And I tested, noticed and fix a bug related to this just now: Fix receiving keys like AWSD in TCastleControl on VCL · castle-engine/castle-engine@7ba299a · GitHub . We had some unfinished TODOs specifically for TCastleControl with VCL .

So, everything should work for you with new CGE. Please give Jenkins a few hours to perform automatic tests and then this version will be available for download from Download | Castle Game Engine . You can watch it by observing this page: Comparing snapshot...master · castle-engine/castle-engine · GitHub . When it will no longer show the commit “Fix receiving keys like AWSD in TCastleControl on VCL”, it means that commit is now part of CGE downloads.

P.S. In case of related question: To handle specifically arrow keys correctly, remember you have to call MyCastleControl.PreviewFormKeyDown, see examples/delphi/vcl. This is necessary specifically for arrow keys and space, which are handled in a special way by WinAPI and thus VCL. This hack is not necessary for TCastleControl on FMX.

1 Like

Oh I see, I was thinking whether there might be some trick in using of VCL, but was not aware of that it’s a bug. I have tried the newest build and it works now, thank you.

1 Like