Godot Version
4.2.1
Question
i am trying to use godot’s physics output to do some sort of fake physical rotation in a racing game. so i have a vehicle, and i have deduced what direction the ‘ground’ is.
the problem is that i need to be able to set my vehicle’s 3d body ‘rotation’ based on this information, and some sort of “direction”. since there are infinite rotations around this vector, my vehicle needs a consistent way to decide which one to face in.
this is especially important in a racing game where i’ll be using the forward direction from this rotation to decide what direction the vehicle will drive in. so far i have been attempting to use look_at like so
$body.look_at(global_transform.origin + down_vector)
where $body is a child of my non-rotating rigidbody sphere node that contains the entire 3d model of the vehicle.
using look_at obviously is producing inconsistent and unpredictable rotations, but it is successfully keeping my vehicle “flat” to the ground which is good. the problem is that it randomly rotates the vehicle’s body to some rotation around the surface normal axis. i need a way to make this rotation stay as consistent as possible, and then i need a way to use some ‘direction’ scalar to rotate the rotation around that axis. ideally changing this ‘direction’ will be how you turn.
any thoughts on how to implement this? i’m a little overwhelmed by godot 3d rotation syntax, so maybe look_at isn’t the right function to use here. thanks