controlling around a Sphere 2D

Hello, I hope this is the right place for my problem.

I am looking for days without success.

I want my character to move around a cticle.

Unfortunately, I can not script. But since I have no other making it I need to learn it.

The solutions I’ve tried so far have not worked with the gravity of the planet. And now I’m stumped …

1275359--57057--$planet.png

for gravity, I use:

var planet : GameObject;
var gravity = 2;
function FixedUpdate(){
rigidbody.velocity = ((-transform.position + planet.transform.position) * gravity)/ (Mathf.Abs(-transform.position.x + planet.transform.position.x) + Mathf.Abs(-transform.position.y + planet.transform.position.y) + Mathf.Abs(-transform.position.z + planet.transform.position.z)) ;
transform.LookAt(planet.transform.position);
}

The gravity requires a rigidbody which means I can not use the character controller.
if I understand correctly.

Thanks for the help and greetings from Germany

rigidbody.AddForce((planet.transform.position-transform.position).normalized*gravity);

you get the vector pointing from the “player” towards the planet, normalize it (to be independet from the distance always length 1) and multiply it by gravity.
you should not assign it to the velocity as this makes the character move with same speed towards the planet. you want to add a force so the character accelerates towards the planet. for jumping add a force in the other direction.
as for controll the movement left/right i guess you are working on a plane (fe xz plane) so make sure your coordinates reflect that and set the ycomponent to zero to avoid getting out of the plane.

another, maybe simpler approach is not to move player but the world so when you controll left the camera and the planet are rotated right and the player keeps its position. this way you can use the normal gravity in one direction and maybe even use a character controller (have never used them so i don’t know). but this gets a hassle when you have lots of stuff to rotate properly.

Thanks so much for the new gravity idea !

But I lack the knowledge to create a control which is what brought me here in the first place…
Obviously, I can’t do it horizontal since the planet is round. All the other things I tried cause the “player” to flip around at the planets pole.

I have no idea.

The ‘player’ should move on the disc like planet in 2d.
but the standard unity controll assets include all gravity settings or are based on these…

I am still not able to write my selfe a controll script.
That’s why I need some help

1277989--57348--$circle.jpg