Planetoid Gravity

Hello, I’ve started a project in wich there are planetoids but I have a problem making my custom gravity.

My first tought was to first make the player look to the center of the planet and then apply the rotation to look the new up, but there is a problem I didn’t count, when unity uses lookAt at the planet the up vector will always be upside the planet so the player will be always looking at the north of the planetoid and that’s a problem jajaja.

My second tought was to make the down vector of the player to look at the center of the planet but I don’t know how to make that.

can Anyone help me?

Planetoid gravity has been covered numerous times on UA. The solution will vary somewhat based on your game mechanic. The typical solution using a smooth sphere is:

var worldUp = transform.position - planetoid.position;
transform.rotation = Quaternion.FromToRotation(transform.up, worldUp) * transform.rotation;

And you want to do this alignment before you process ‘y’ rotation code for the object.