Godot Version
4.2.1
Question
Good morning to all of you : ) Except for me who woke up having this unforeseen event. I’m making a game very similar to Rockless Getaway 2, in which you control a car that runs away from the police. Simple, right? Apparently not for me. It seems like my car only likes 2 numbers: 8 or 80. Either he flips over at the slightest movement or he can’t turn the corner. I’ve tried to customize, but I don’t think I’m good at it. Can anyone here tell me what the best settings are for it? I think it would be something like an F1 car but with improved control
Maybe a screenshot of the Rigid Body settings can help others help you?
Without seeing the code or any examples/screenshots I can just shoot in the dark:
This sample code provides basic steering, acceleration, and braking controls for a car with wheels as children of the RigidBody. They can also be adjusted. Not sure this is what you are asking, but it’s an attempt.
extends RigidBody
var max_steering_angle = 30
var max_speed = 100
var max_brake = 100
var engine_force = 100
var brake_force = 100
func _physics_process(delta):
var steer_input = Input.get_action_strength("steer_right") - Input.get_action_strength("steer_left")
var throttle_input = Input.get_action_strength("accelerate") - Input.get_action_strength("brake")
var speed = linear_velocity.length()
# Steering
var steering_angle = steer_input * max_steering_angle
for wheel in $Wheels.get_children():
wheel.steering_angle = steering_angle
# Engine force
var engine_force = engine_force * throttle_input
for wheel in $Wheels.get_children():
if wheel.angular_speed < max_speed:
wheel.add_torque(Vector3(0, engine_force, 0))
# Brakes
var brake_force = brake_force * Input.get_action_strength("brake")
for wheel in $Wheels.get_children():
wheel.brake = brake_force
# Rolling resistance
apply_central_impulse(-linear_velocity.normalized() * speed * 0.1)
Hmm… I know it’s a very broad question and without images it makes the job difficult for you smart people… But I wasn’t going to post a picture of the car, I was going to go further… I even have a video. However, since my account here is new, I couldn’t send it… : (
About the code, I didn’t understand very well some parts like the fact that it was Extends RigidyBody, but I don’t think I said it was a VehicleBody3D. There are also some errors in the part where you pick up the tires, there is no function: ‘add_torque’. I looked in the documentation and it has a function called ‘apply_torque’ but it gave an error anyway. But lucky for us, I already have a reasonable script of the car. What I really want is just for someone to tell me which VehicleBody properties I should use and which I shouldn’t