Switching the camera to walk/fly mode in Blender

Adjusting the camera position in Blender the usual way isn’t always convenient, especially in large, open scenes. For this reason, Blender offers the ability to switch the camera to “walk” or “fly” mode. In these modes, we can control the camera as if you were playing a first-person video game. The camera is moved using the arrow keys or the WASD keys familiar to computer gamers.

We can switch the current camera to walk mode, first by switching to the camera view (pressing the 0 Ins key on the numeric keypad) and next, selecting “View – Navigation – Walk Navigation” from the 3D viewport menu. To exit walk mode, press the Esc key or right-click.

To enable “fly” mode, everything is exactly the same; just select “View – Navigation – Fly Navigation” in the 3D viewport menu.

These two modes are actually not fundamentally different; in fly mode, the camera moves at a faster rate, making this mode more convenient for large landscape scenes where we need to quickly navigate large distances.

We can also switch the camera to walk and fly modes using the Blender Python API.

Both of these modes are implemented as modal operators that we can easily call in our code.

The operator for switching to walk mode:

And to fly mode:

Both of these operators are context-sensitive. This means they can be called directly from the 3D viewport window context, but if we need to call them from another area, for example, from the Text Editor code, we need to override the context.

For both of these operators, we need to redefine not only the area but also the region of the current area in the required context.

Let’s switch to walk mode using code executed in Blender’s text editor.

Get the 3D viewport area pointer:

And the pointer to the region of the area:

Now, in common way, we call the operator that enables walk mode for the current camera by temporarily overriding the context.

The camera in the 3D viewport will switch to the walk mode.

Note that if you switch to walk or fly mode outside the camera view, the entire 3D viewport will switch to the desired control mode, and the entire 3D viewport will be controlled by the arrow keys/WASD keys.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments