The question is answered, right answer was accepted
I have rotation problem, I look forward to helping.
Hi everybody.
I tried many ways but still did not solve the problem. I'm not really good at math so I hope everyone will help me.
The problem is that I need to move the car around the planet. The car has been spinning around the planet already, but until I needed the car to change direction, an error occurred. Every time the car moves to the bottom of the planet, the car will orbit itself.
If I release the key, it doesn't stop right away but slowly returns to the original angle.
I tried separating it into two Rotate functions, but strangely, only one worked.
I am really stuck, I hope for the help of everyone. Thank you.
This is the entire source:
 public class Testing : MonoBehaviour
 {
     public Transform car;
     public Transform planet;
 
     public float planetRadius = 7.5f;
     public float speed = 3;
     public float angle = 30;
 
     private void Update()
     {
         float horizontalInput = Input.GetAxis("Horizontal");
 
         Vector3 normal = car.position.normalized;
         Vector3 surface = normal * planetRadius;
 
         // Move Foward
         car.position = surface + (car.forward * speed * Time.deltaTime);
 
         Quaternion turnLeftOrRight = Quaternion.AngleAxis(horizontalInput * angle, Vector3.up);
         Quaternion upVectorOnSurface = Quaternion.FromToRotation(Vector3.up, normal);
         car.rotation = upVectorOnSurface * turnLeftOrRight;
     }
 }
Here is a video demonstrating the problem: Youtube video
The problem has been resolved. I have divided them into 2 objects. A parent object for movement, a child object for turning directions.
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                