Vehicle Movement (Turning)

Hi all,

How can I make something (A car) turn (Rotate) only when it is in motion,
like a real car? I am sure some of you have tried my game out (CITY OF DEATH)
and if not, it should be on the first page of the Finsihed Games section, and the
reason I am showing you this is because that is exactly how I DON’T want my
cars to behave. It is very un-realistic and very not good. For example: When
stationary, the car will still rotate when not in motion. Can someone help me,
Please… I’m desperate… :frowning:

Thanks :slight_smile:

keyboard sensor connected to and connected to two motion actuators one for loc y of .05 and rot z.01.That should
do it for you.

Generally you can use the vehicle wrapper. It calculates the turning forces from the wheels angle.

A nice tutorial about the vehicle wrapper you find here. You can also download a blend for 2.6.

I don’t fully understand this, here is the .blend file, what have I done wrong? (Probably everything)…

I would recommend using the Vehicle Wrapper Method. At first it may seem complicated, but if you watch the tutorial you’ll probably get a clearer picture on how to work with it. But if you’re looking something much simpler maybe this blend can help you on your way:


SimpleCar0.blend (111 KB)

I corrected it for you.
Make the first keyboard sensor into x key.

very well done Raco !

what kind of calculation is this?

	frRate = 60.0
	rot = vehicle.getLinearVelocity(True).y/frRate
        own.applyRotation([-rot, 0.0, 0.0], True)

a bit approximate :smiley: :wink: (not too precise)

You’re right. :yes: I don’t even know why I added this variable. :eyebrowlift2: I guess it’s because I just started to learn scripting with python.

But of course the previous method is not ideal for vehicle movement. The vehicle wrapper is much more suitable.

I learned a lot from the examples on Hope this blend will help, RandomPickle97.


    if turn == 0:
        turn = 0
        turn = -turn * turnAngle / 180.0

should be shorter:

    if turn != 0:
        turn = -turn * turnAngle / 180.0


SimpleCar1.blend (122 KB)