How to not turn Vehicle it self on the floor

Godot Version

4.4.Dev 2

Question

I’ve found that vehicle automatically turns it self on the floor Vector3 (0,1,0)

how should I avoid that?
so that I can simulate driving on the planet? and program my own physics
like up side down

thanks

you can change the physics settings of your project while runtime:

hmmm sadly it’s a direction for everything it’s not a direction towards an object or am I mistaken and don’t understand it fully?

You are right.

This is how to get a directional vector from point a to point b

func get_dir(point_a : Vector3, point_b : Vector3) -> Vector3:
   return (point_b - point_a).normalized()

Since the VehicleBody3D inherits Rigidbody3D you can set its gravity scale to 0 and apply your own custom gravity force in your desired direction.

var gravity_center : Node3D
const gravity : float = 9.81

func _read():
   gravity_scale = 0

func _physics_process(delta):
   var gravity_dir = (gravity_center.global_position - global_position).normalized()
   apply_central_force(delta * gravity * gravity_dir)

yes but won’t that mean that car at bottom will have up to the planet right position and car on the top will have to the sky position?

If your vehicle is pressed to the ground it should theoretically always be rotated correctly. If you want to set your vehicles rotation to the correct rotation on ready this should be how (you might have do adjust the local_rotation += part):

var gravity_center : Node3D

func _ready():
   look_at(gravity_center)
   local_rotation_degrees.x -= 90