# Car barely steers at slow speeds?

When the car is stationary, it’s almost impossible to turn. At normal-fast speeds it steers just fine.
I know the value for ‘turn amount’ is set very low, but it’s perfect for when the car is at higher speeds

``````
##################################################  Steering

def Steering( vehicleID, controller):

# set turn amount
turn = 0.05

# get steering sensors
steerLeft = controller.sensors["Left"]        # sensor named "Left"
steerRight = controller.sensors["Right"]    # sensor named "Right"

# turn left
if steerLeft.positive == True:

turn = turn

# turn right
elif steerRight.positive == True:

turn = -turn

# go straight
else:
turn = 0.0

# steer with front tires only
vehicleID.setSteeringValue(turn,0)
vehicleID.setSteeringValue(turn,1)

###############################################
``````

Didn’t paste the entire script, but is there something missing here?
Or does this problem have nothing to do with steering? Could it be the model?

That doesn’t sound like a problem. In fact, it makes perfect sense.
It probably adjusts the steering value at the rate of the movement value. That’s how I set up my vehicles.
You should check through the rest of the script, see if there’s a value somewhere that matches turning to movement, and change it.

You should calculate the turn amount value in a way that’s dependent on the linear velocity of the car.

Something like…

``````
SpeedX, SpeedY, SpeedZ = car.getLinearVelocity(True)

if abs(speedY) &gt; 1:
turn_amount = abs(SpeedY/10)

``````

Looked through the script, couldn’t find anything.
Still relatively new to scripting, how would I implement that script into this one?

Insert the first line near the beginning of the code and replace the value you have for turn_speed with the value shown (will only work if the car object itself has the script).

I updated the script to use a division because it will mean higher values for low speed.

How near? And inside the part of the script I posted? Or the literal beginning of the script (which in this case is Powertrain)
Sorry… :o

Not right at the beginning, but anywhere after the line that says something like myObject = myController.owner

If you still don’t get it, then I advise you hop onto http://www.tutorialsforblender3d.com/ and study how Python is used in the many pieces of example code found there throughout its API documentation (that was what got me to really start getting Python).

Still couldn’t figure it out.

Is it the line that says “car = controller.owner”?
ANYWHERE after the line? even right below it, like this:

Or could it be something wrong on with the other lines?

You got the first part right, but the second part is not indented property (convert your whitespace to tabs, make sure the option ‘tabs as spaces’ is disabled, and then line up the second line of the ‘if’ statement and hit Tab).

after looking at your second peice of code. Is anything scaled down? Your turning variable is not going to take affect unless your car is moving greater than 1(bu) m/s . So you may not be going fast enough for it to kick in. Do you have an else:turn = this. If not, the console should be kicking out an error till your rise above a speed of 1. adjust the speed in the if to a lower amount, Like .01(you could even do 0, so that if you are moving at all the turn is adjusted, else i think it will kick out an error till you at least move in some direction), so that it always is working. Once your sure that it is indeed working. Adjust the denomintator in Ace’s fraction. And just in case ace wasnt clear. I think hes saying you should use a good tab, instead of one space.

if blah blah:
(tab)do this

Alright, so I lowered the value, and have tried indenting.
Kept getting an error in the console in regards to the turn = abs (Speed Y/10).

Figured I have to indent it, not sure to where exactly. Hitting TAB once didn’t work.
Accidentally closed Blender and tried it again. Got an error from the other one now.

Just to make it a whole lot easier, which letter/number should be lined up with what?
if abs(speedY) > 1:
turn_amount = abs(SpeedY/10)

line the t up directly under the i and it over.

I’d have to check your code but I still bet you anything because your using turn before it gets defined. Turn does not get defined until your speed goes above 1. So your trying to use turn from the start, and It hasnt got established yet, because your speed has not increased above 1 yet. its trying to use something that does not exist.
You could try a little fix by going:

``````

if abs(speedY) &gt; 0:
turn_amount = abs(SpeedY/10)
else:
turn_amount = 0

``````

It could be that or it could be that if your car is sitting still, its trying to divide a speed of zero . You can’t do that either

It probably wont get you the desired effect. But you can see if it kills the error. Also, you are using turn and turn_amount. Are those 2 seperate variables? hard to tell, I see your original code used turn, but now you have turn_amount. I cant really tell whats going on.

Oh yeah, in that script I removed “amount”, as the original didn’t use it.
Not sure if it changed anything.

Also, the cars all get a running start at soon as “P” is pressed. They do go pretty fast

I had been using that same script. When I originally got it, I think the turn was set to 0.3. I have done a lot of tweaking on it but my turn is still close at 0.2. I tested your 0.05 and it barely turned unless I was going fast. I should mention that you might want to adjust the mass of your car. I found that 400 works well for me on a 90 Eagle Talon and the gas power is boosted up to 1600. It gets me an accurate stock 1/4 mile time.

Problem is setting it to anything past 0.08 is too fast.
Could very well be because the cars are too small. They’re about 4x2 when lining them up to the default grid.

I have tried using different masses, though I didn’t notice if they affected anything other than ramming power. I currently have it set to 200…

I think what I might do is find a way to make sure the player is always in motion. Like if you come to a dead stop, or are turned around, you get set back on the track in the proper direction with a rolling start. That way no one will notice the steering problem, and it won’t break the sense of speed and fluidity.

That’s what I’m really going for, here. An unrealistic, exhilarating racing game with brutal crashes and lots of jumps.

Can you post your script as-is? Maybe I can help?

i’m not sure if size would be a factor as long as the mass is correct. are you steering with the front wheels? too much power will lift the front wheels and cause you to understeer. its possible that when you get going at a decent speed, the weight comes back down on the front wheels and gives you control back. there is a lot of stuff going on with all the suspension and drivetrain configurations.

Thanks Michelle, that’d be great! Here’s the script in it’s entirety:

``````
# Main Program
def main():

# get the current controller
controller = bge.logic.getCurrentController()

# get vehicle constraint ID
vehicleID = ConstraintID(controller)

# brakes
brakes = Brakes(vehicleID, controller)

# gas & reverse
Power( vehicleID, controller, brakes)

# steering
Steering(vehicleID, controller)

########################################################  Vehicle ID

# get vehicle constraint ID
def ConstraintID(controller):

# get car the controller is attached to
car = controller.owner

# get saved vehicle Constraint ID
vehicleID = car["vehicleID"]

return vehicleID

########################################################  Brakes

def Brakes(vehicleID, controller):

# set braking amount
brakeAmount = 40.0      # front and back brakes
ebrakeAmount = 100.0    # back brakes only

# get sensors
reverse = controller.sensors["Reverse"]        # sensor named "Reverse"
brake = controller.sensors["Brake"]            # sensor named "Brake
emergency = controller.sensors["EBrake"]    # sensor named "EBrake"

# emergency brakes
if emergency.positive == True:

front_Brake = 0.0
back_Brake = ebrakeAmount
brakes = True

# brake
elif brake.positive == True and reverse.positive == False:

front_Brake = brakeAmount
back_Brake = brakeAmount
brakes = True

# no brakes
else:

front_Brake = 0.0
back_Brake = 0.0
brakes = False

# brakes
vehicleID.applyBraking( front_Brake, 0)
vehicleID.applyBraking( front_Brake, 1)
vehicleID.applyBraking( back_Brake, 2)
vehicleID.applyBraking( back_Brake, 3)

return brakes

##########################################  Gas & Reverse

# gas and reverse
def Power( vehicleID, controller, brakes):

# set power amounts
reversePower = 200.0
gasPower = 150.0

# get power sensors
gas = controller.sensors["Gas"]                # sensor named "Gas"
reverse = controller.sensors["Reverse"]        # sensor named "Reverse"

# brakes
if brakes == True:

power = 0.1

# reverse
elif reverse.positive == True:

power = reversePower

# gas pedal
elif gas.positive == True:

power = -gasPower

# no gas and no reverse
else:

power = 0.0

# apply power
vehicleID.applyEngineForce( power, 0)
vehicleID.applyEngineForce( power, 1)
vehicleID.applyEngineForce( power, 2)
vehicleID.applyEngineForce( power, 3)

##################################################  Steering

def Steering( vehicleID, controller):

# set turn amount
turn = 0.05

# get steering sensors
steerLeft = controller.sensors["Left"]        # sensor named "Left"
steerRight = controller.sensors["Right"]    # sensor named "Right"

# turn left
if steerLeft.positive == True:

turn = turn

# turn right
elif steerRight.positive == True:

turn = -turn

# go straight
else:
turn = 0.0

# steer with front tires only
vehicleID.setSteeringValue(turn,0)
vehicleID.setSteeringValue(turn,1)

###############################################

#import bge
import bge

# run main program
main()

``````

Pretty sure the car is RWD, and it does steer with the front wheels.
I’ll whip up an example .blend!

EDIT: Here is is:
http://www.pasteall.org/blend/31711

All other scripts can be found in the file

Oh, that’s right, it’s a tutorialsforblender3d script, isn’t it?
The big issue with those scripts is that the indenting is very rickety. Any edit you make can destroy the script solely because of the indenting. I don’t understand why or how and I’m not going to try to, but that’s just my experience. =P

Now, I just have to ask, what /exactly/ is the problem here? Because as far as I’m aware, the car is supposed to have a slower turn rate at slower speeds…

It is, I took out the header in the script above ^
I have the script set up to another car in some other file, I’ll try and hook it up to this one and see what happens!

EDIT: Found the script, and it works incredibly well!
The brakes and e-brake both work, and though the steering is still screwed up, it’s not as bad.
The car’s acceleration and braking are a lot quicker now too