I'm trying to make a game in Unity where the player character is a ball (a sphere), and the game world is a planet (a very large sphere) that the ball can roll around on. The ball can be rolled in any direction, via the arrow keys. If the player holds the right arrow, the ball should roll smoothly to the right, all the way around the planet not leaving the ground, until it eventually reaches back to where it started. The camera follows the ball third person such that the ball always appears in the same position in the screen and the planet appears to be moving underneath it.
My question is, how can I use rigidbody.AddForce() to roll the ball in the way described above? What I think I need to do is to take the vector I get from taking the input values on the horizontal and vertical axes:
float moveX = Input.GetAxis ("Horizontal"); float moveY = Input.GetAxis ("Vertical"); Vector3 inputMovement = new Vector3 (moveX, 0.0f, moveY);
And rotate it somehow, so that I'm applying that vector as force to the ball but in the direction that's tangential to the point on the planet that the ball is currently on, and then apply it as force to the ball's rigidbody. So if you're looking at the planet head on, and the ball is at 3 o'clock, pressing the right arrow key should apply the force directly downwards.
Can anyone help me out here? I think it's probably really simple but I'm having trouble figuring it out exactly.