Object motion makes it fly

Hello everybody,
I was experimenting different movements on an object, I’ve set motion based on location and rotation.
I want my object to go in the direction given by the rotation when it’s on the Z axis, but for the rest I don’t want to because if make a rotation up or down the object go up in the air.
My object is set as dynamic by the way. It must stay on the ground at all time and not fly anywhere. The same thing applies for lateral and backward movements.
I was just wandering if there was an easy to do it in the logic editor or if it needs a python script.
I tried to uncheck the “L” in the motion actuator, then it doesn’t fly anymore, but it only goes forward and doesn’t follow the direction of rotation on the Z axis.
I’ve joined picture of my logic editor, so you better understand it.

Thank you in advance for any help you may give me.


do not use Loc for dynamic objects. This is not a motion but a “teleportation”.

Better use:

  • forces
  • velocities
  • servo motion

Regarding your problem, split your objet into multiple object.
One object is dynamic (Z-Axis rotation only). You can rotate it in the direction you want with y-axis only. You can apply motion to it (x and y).
To this object parent another one (empty or mesh object) this one can perform the up/down rotation.

For more suggestions I need a some more details on your requirements.

In my understanding you want to rotate around the world z-axis, say by an angle psi (azimuth), and by an angle teta (elevation) around the local x-axis.
For a given speed along the (local) y-axis your translations should then be proportional to cos(teta)*cos(psi) along the world y-axis, and to -cos(teta)*sin(psi) along world x-axis.
The answer is then: you can’t do that without python (at least in part).
The good news are that the relevant code should not be too complex, at first glance…

…a simple demo based on the above principles is here:

AzElev_simpleDemo.blend (458 KB)

I tried Monster’s idea, but it didn’t work quite like I wanted. One split part would rotate without making the rest of the object move while not affecting the elevation. That was close but I wanted my object to move completely without its trajectory being affected by the upwards/downwards rotation. Thank you though.

As for mb10’s solution it worked. I changed the always sensor by a keyboard sensor, I did it with the backwards movement too, and it works perfectly how I want it. I added lateral movements and it it does everything it supposed to.
Frankly there was no way I would have been able to write that script, I mean I tried to understand it, but I really don’t, I don’t understand the maths behind it. That said, thank you very much for writing the code, you made my day.

do you mean something like this?

(very quick and very dirty demo)


smitchel.blend (80.6 KB)

it’s kind of like this except I wanted the whole object to rotate as well. The movements are good, it stays on the ground even when the “head-like” object rotate up and down, but the part beneath should rotate too while staying on the ground.
See the blend I attached, it’s mb10’s work modified to suit my needs. It might be easier to understand if you have a look at it.

Z=Forward, S=Downward, Q=Left and D=Right. Those are movements. I don’t have an american keyboard, so it’s not qwerty but azerty. I don’t know how keyboards are in Germany, but if it’s qwerty then forward/downward might seem odd.
For rotations, use up/down/left/right arrow.


AzElev_simpl.blend (503 KB)

…a very rapid object indeed!

Let me add a suggestion for your next learning step: instead of using two (almost) identical scripts to manage forward/backward movements, in the logic editor you could add a property called ‘Vitesse’ (of type float), which is set positive or negative by two property actuators, controlled by Z and S keys, respectively (and both keys should be used to trigger the script, too).
In the code you could then read the speed as follows:

V = obj['Vitesse']

The advantage would be that all the algorithms are concentrated in the same place, and in the future you will have to ‘maintain’ only one script, rather than two.

So I’ve done what you told me, and it works only there’s a little bug, I don’t understand. When I go forward the first time, it is fine, but then if I go backward forward, the object shifts a little bit in the opposite direction and then move normally. With a camera following the object it’s going to be very uncomfortable. I’ve attached the blend file, so you can see the problem.


AzElev02.blend (504 KB)

just make the underlying object invisible

It may depend on the script running for a while before the speed property is updated, so the object initially runs in the previous direction.
It seems it can be solved (please confirm: I cannot clearly appreciate the behaviour on my PC) by adding a new pair of S-Z keyboard sensors, both set to INVERT mode, then logically and-ed to another property actuator (see figure below) that resets the speed to zero when both keys are relaxed.

In addition, in the version you sent to me one of the property actuators was set for -+5 (i.e. two oppositee signs in front of number 5) and this should be corrected as well.

P.S.: I don’t really like such proliferation of logic bricks, but for the moment let’s stay with that…

I changed the logic exactly like you said and like your screenshot, I made sure I checked the sensors to Invert. I’ve set the -+5 to the right value as well, but nothing has changed, the problem remains.

In the attached file I have lowered the frame rate (from 60 to 20 frames per sec (FPS)) in order to slow down the simulation and make the phoenomenon clearly visible, if present.
When the two '“new” sensors are disconnected, the problem is evident, but in my system it disappears when they are reconnected.
Can you reproduce the experiment on your PC?

AzElev02LowFPS.blend (468 KB)

It works! You know what, it’s all my fault. I compared your file with mine, and I found that I forgot to assign the “Vitesse” property in the last actuator. Now it works fine. I’m very sorry I missed that. Thank you very much for taking the time to help me.

…it was instructive for me too!