Fly mode in game engine?

Hello all.

I am (slowly) working on a process whereby I export Revit models to Blender, bake some lighting, then make the models available for my fellow designers/clients to walk around in realtime. It has become possible thanks to the great advances in FBX import and baking recently. Great work Blender devs!

One of the stumbling blocks for users is having to open in Blender. Not easy for people who aren’t computer savvy. A BGE standalone version would be much better.

But I have really struggled to get anything half as good as Fly Mode, including the ‘tab to toggle walk/ghost mode’ function, in the BGE. Hours of tinkering have left me not much closer. Hitting tab to switch to ghost mode, for example, is something I have struggled with.

Does anyone have any suggestions as to how I might get a version of Fly Mode working in BGE?

On a related question, does anyone know if I would get better performance if I exported to e.g. Unity? Some of the models I am using really bog down the engine due to shear weight of vertices.

Thanks in advance for any advice.

here you go

actor 1 = walking actor
wasd mouse

actor 2 = fly camera
wasd mouse and mouse wheel

press 1 and 2 to switch back and forth

at some point I will make it so it swaps one for the other in place first, (swaps rigs where the current rig is)

Attachments

MasterControlMouse (2x).blend (576 KB)

Wow! Thanks both of you. I had tried to use the mouselook script before, but somehow hadn’t found the official BA thread which helps me somewhat to understand it. I’ll have another play.

BluePrintRandom’s .blend is fantastic too. Well over my head, but looks like just what I need. Having it react to obstacles is great. A couple of things that would really help me out if you wouldn’t mind …

  1. Can I make up/down in fly mode be Q and E keys? I don’t have a wheel (Logitech Marble Mouse trackball), so can’t use that option. I tried changing the Receiver2 Sensor to Keyboard/Q, for example, but nothing happens when I press it.

  2. I’d like to make the A/D keys make the Actor1 strafe rather than rotate, then have the mouse not restricted to about 90 degrees (as it is now). Is that a simple change? I looked at the MovmentFiltersSpin and lookMouse scripts, but can’t see where/why the movement is restricted.

I have found that the decimator modifier helps a lot with reducing vertex count without impacting too much on the visuals. Gives me half a chance of Smart UV unwrapping within 24 hours for big meshes too. How I wish that the unwrapping was threaded. I have maybe 2 million vertices and 4m faces in some meshes, so unwrapping is very slow. I can break them down into smaller parts to make more manageable, but my aim is to keep the amount of interaction with the meshes to a minimum, as I’d like to be able to repeat the process every week or two as the design changes so the more faffing about, the more time-consuming that becomes. Decimate seems to offer the middle ground that I have been looking for.

Thanks again both of you. Much appreciated.

added a third receiver press 3 to switch to it

Attachments

MasterControlMouse (3x).blend (585 KB)

Here’s another solution. The movement/rotation speed can be configured in configurecallbacks.py, and the keybindings in configurekeys.py

One thing you may/maynot like is the lack of locking the camera upright. If you want me to add this in I will.

Attachments

FlyMode.zip (77 KB)

You lot are great! Thanks so much. Plenty for me to investigate there.

sdfgeoff if you were willing to add the camera-locked-upright thing then that would be even better.

Now I just have to work out how to get one actor to appear just where the other one left off and between those scripts hopefully I can get something working.

Somewhere there must be the code for the Fly Mode camera. Would be nice if it was a standard actor in BGE. One day …

Right, here you go, camera lock enabled. Tab to toggle gravity.
FlyMode.zip (78.2 KB)
Any other features you want?

Note that you ca turn the camera all the way upside down, and when in fly-mode, you no longer travel the way the camera is facing. I’ll have a further play with it tomorrow.

Wow, you’ve created almost the exact thing that I was after! Thanks so much sdfgeoff. You’ve saved me hours of time trying to work it out for myself. Even with all the generous help from others, it was going to take me a while to get to this point.

Seeing as you offered, and this is only if you fancy it …the only other major things that I’m looking for is for the flying mode to be ‘ghost’ (i.e. can fly through floors/walls) and the ability to walk up stairs. One of the challenges I’ve faced is that the logic bricks won’t allow switching to/from ghost mode, but maybe scripts can do it. There used to be a character physics option (I can’t find it in 2.73) that lets the actor walk up stairs.

So for stairs, you have to create an invisible plane on an angle for the character to slide up on.
I don’t see any easy way to make the player ghost in the python API, but have a few ideas. I’ll give it a shot later today.

Actually there is a better way nowadays. I found it after a bit of digging around (I wasn’t in Game mode previously. Oops).

Under physics/character you can define a step height. I have put a .blend here that shows it. Two characters: one with a step height of 0.4 which fails at the last step. The other has step of 1.0 and climbs the lot. I can’t just add this to your character, because it means changing from Dynamic to Character physics.

Maybe the two are incompatible. Which would be a shame, because it’s nicer than having to add invisible planes everywhere (not practical in my case, with many stairs to consider in various configurations). Also gives a nice bumping-up-the-stairs feel to the camera movement and avoids sliding backwards down slopes when you stop moving.

I wonder whether making all the meshes flip to ‘no collision’ would be a workaround. I generally only have maybe 5 meshes (albeit rather large ones) which might make it work.

Here is a .blend showing a portion of a building (I deleted the rest to keep the file size down) with sdfgeoff’s character in it. Figured it might help to have some context. No stairs in this one though. Just needs the bgeinput.py file in the same folder so the script can find it.

Slight problem is that the character falls through the building until it hits the ground plane. Maybe the game engine struggles with the collision bounds (I tried them all). Another thing that Fly Mode has nailed, but the BGE might struggle with :frowning:

just parent the level to another object, in ghost mode?

I can do stairs using dynamic, you just need the body hitbox to be a convex hull. make it a cube, then extrude the bottom to a point. remove doubles.

then in the movment filter,

if move = forward :
if own.localLinearVelocity.x<max:
own,applyForce((120,0,0),1)

this way you can walk right up stairs, if the number is high enough on force.

This system is in actor 3, but I have not made his movements fully dynamic yet

falling through the level, is because the type of movement I was using (applyMovement vs Apply Force)

Attachments

MasterControlMouse (4x).blend (586 KB)

That’s nice! Stairs working well.

Can you help me bring it into a new file? I tried grouping the whole lot then appending it (shift-F1) so that everything comes in from your file, but when I hit P I don’t have control of any of the actors like in the original file. They just fall to the ground and sit there. I can see all the scripts and logic bricks from the original file.

Sure, I can even try and make it more portable,

I use the same system in my own game.