I'm using Blender 2.68 to create a first person simulator of an astronaut floating around a space station. I'm using WASD to move the camera up, down, left and right and the arrow keys to rotate it.

The problem is as soon as I take my finger off the key the movement stops dead. I want the camera to continue moving after you let go of the key and then using the opposite direction key to slow down and eventually stop and then move in that direction the longer you hold the key to simulate realistic anti gravity movement.

I'm very new to Blender and don't understand the finer points yet. Hope what I've said makes sense.

  • $\begingroup$ You need to implement Newton's laws of motion: en.wikipedia.org/wiki/Newton%27s_laws_of_motion $\endgroup$ – Ezra Aug 12 '16 at 15:27
  • $\begingroup$ I'm sure that's true but what does that mean in Blender terms? $\endgroup$ – Nick Aug 12 '16 at 15:43
  • $\begingroup$ That the acceleration should be depending on whether a key is pressed, not the velocity itself. $\endgroup$ – Ezra Aug 12 '16 at 16:39
  • $\begingroup$ I've thought of a simpler way of looking at it. I want the WASD keys to affect the speed of an object as opposed to just simple motion. Is that possible, if so how? $\endgroup$ – Nick Aug 13 '16 at 8:46
  • $\begingroup$ Just out of curiosity, why 2.68? $\endgroup$ – TARDIS Maker Aug 15 '16 at 2:41

If you want 0 gravity movement for your character, The first step seems rather obvious: turn off the gravity in your scene. To do this, open the world settings, and set the gravity to 0.

enter image description here

Great! now the scene has no gravity.

enter image description here

But we have a problem - the objects stop moving completely. that should not happen if we are simulating space. This is done by blender as an optimization. Essentially, when blender sees that an object is going slow enough, it just halts it's position (stopping the calculations for that object, freeing up processing power.) Once another object applies a force to the "sleeping" object, the physics calculations will resume for that object. We don't want that, so check "no sleeping" on all objects you want to continue moving indefinitely. This is perfectly fine to do on a few simple objects, but Beware - doing this on a lot of objects or a few more complex shapes could potentially eat up a lot of processing power.

screenshot here of checking no sleeping

enter image description here

These results are much closer to what we want - but we still have have a problem. The objects are slowly decelerating. Why? This is because of the dampening on each object's rotation and location, set by default. This dampening is normally to simulate air resistance, which adds to the realism on most games. We don't want that resistance here, so we can also set the dampening to 0 on the character. (Here I'm setting the dampening to 0 on both example objects, do this for all the objects you don't want to slowly lose velocity.) Changing or eliminating the angular or linear dampening should not significantly effect performance.

screenshot here of no dempening

enter image description here

Now we have (for this question's sake) realistic 0 gravity movement. Now to add thrust. This is actually simpler than it might sound.

All you need is a logic setup like this. enter image description here

(The X axis is forward on this example object, which is actually bad practice - it should be the Y axis. adjust your logic setup depending on which direction is forward on your character.

This setup ignores the rotation of our example cube, it only controls linear velocity. To make it work with rotation, simply use a similar setup, but influencing torque instead.

  • $\begingroup$ Thanks a lot! I was beginning to think it was impossible. I have a couple of additional questions; 1. sometimes when the camera is moving about in zero G it will randomly start spinning out of control. Is that an unavoidable glitch or is it fixable? 2. Can I program the spacebar to keep the camera still while it's being held? $\endgroup$ – Nick Aug 15 '16 at 11:56
  • $\begingroup$ if your using rigid body physics, and you ram into a static object at high speeds, it could cause your camera object to rebound away while spinning quite fast. How do you have t set up? I'd have the camera's physics set to no collision, but have it parented to an invisible rigid body cube. (put your logic on that cube) $\endgroup$ – X-27 is done with the network Aug 15 '16 at 12:05
  • $\begingroup$ it is pretty easy to have a button to (almost) stop the movement (although it won't look very realistic). On a motion actuator, if you put an incredibly small value in the X, Y, and Z of the Angular velocity, and Linear velocity fields, it will instantly set the velocity of your camera to .001 (which is, for all practical purposes, stopped) $\endgroup$ – X-27 is done with the network Aug 15 '16 at 12:08
  • $\begingroup$ come to think of it, you can put a number (such as, 27 for example) in the "Damping Frames" field - that field determines how many frames it takes the object to reach the target velocity in a particular motion actuator. This will make it so your camera doesn't instantly stop, but will appear as if it is slowing down first, and then stopping. (adjust the number of damping frames for how quickly you want your camera to stop. - 0 will make it stop instantly, larger values will take longer for it to stop.) $\endgroup$ – X-27 is done with the network Aug 15 '16 at 12:09
  • $\begingroup$ I tried using the Damping Frames field but I can't get it to work. Either it just stops instantly like it does without the Damping Frames or either the velocity or rotation stops but the other doesn't. $\endgroup$ – Nick Aug 15 '16 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.