[ So these are my main player script functions and it all works to be able to move on a spherical surface and its rotation is changed constantly as I move on the planet like surface. I have tried adding code to help the player forward direction match that of the cameras while taking into account its effected rotation because it is on a spherically surface but whatever I try it doesn’t seem to work, I would appreciate some assistance on figuring out what I need to add to my script to accomplish my goal ]
void CameraMovment()
{
_horizontal += Input.GetAxis("Mouse X") * _horizontalMouseVelocity;
_vertical -= Input.GetAxis("Mouse Y") * _verticalMouseVelocity;
_vertical = Mathf.Clamp(_vertical, -90.0f, 90.0f);
_rotation = Vector3.SmoothDamp(_rotation, new Vector3(_vertical, _horizontal), ref _rotationVelocitySmooth, 0.1f);
_camera.localEulerAngles = _rotation;
_camera.position = _body.position - _camera.forward * 4.0f;
_body.localRotation = Quaternion.Euler(_camera.localEulerAngles.x, _camera.localEulerAngles.y, 0.0f);
}
void BodyMovement()
{
_rigidbody.MovePosition(_rigidbody.position + transform.TransformDirection(_movement) * Time.fixedDeltaTime);
}
void MovementInput()
{
Vector3 direction = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, Input.GetAxisRaw("Vertical")).normalized * _movementVelocity;
_movement = Vector3.SmoothDamp(_movement, direction, ref _movementVelocitySmooth, 0.15f);
}
void Gravity()
{
Vector3 direction = (transform.position - _planet.position).normalized;
Vector3 bodyUp = transform.up;
transform.rotation = Quaternion.FromToRotation(bodyUp, direction) * transform.rotation;
_rigidbody.AddForce(direction * _gravity);
}