Moon player movement?

I need this script to work so the player can walk around a sphere like it’s a plane, except the rotation is a bit off how the player rotates very quickly once it gets to a certain value.

var speed : float = 4;
var rotateSpeed : float = 4;
var gravityPoint : Transform;
var forwardPoint : Transform;
var rot : float = 0;
var axisSpeed : float;

function FixedUpdate () {
	
	var rotq = Quaternion.LookRotation(gravityPoint.position-transform.position);
	transform.rotation = Quaternion.Slerp(transform.rotation,rotq,10f*Time.deltaTime);
	
	rigidbody.velocity = (forwardPoint.forward*speed*Input.GetAxis("Vertical"));
	
	axisSpeed = speed*Input.GetAxis("Horizontal")*rotateSpeed*Time.deltaTime;
	rot+=axisSpeed;
	
	transform.localRotation.eulerAngles.z = rot;
	
}

did you try to google?

How To Move Around Sphere

	Ray ray = new Ray(transform.position, -transform.up);
	RaycastHit hit;
	if (Planet.collider.Raycast(ray, out hit,
								MF.V3Distance(transform.position, Planet.transform.position) )  ){
		transform.rotation = Quaternion.LookRotation( Vector3.Cross(transform.right, hit.normal) , hit.normal);
	}

it’ll work fine :slight_smile: