How to rotate a Rigidbody without rotating the gameObject?

Alright so lets keep this short n sweet.

I need to do something like the ball movement in the game Kula World, shown below (but with free mouse X,Y look movement) So when I look to the right, that automatically becomes the new “forward” direction.

Kula World Level 1 - 15

I’m still pretty new to Unity, C# and JS in general but if anyone knows how I can edit the stock import scripts for the camera movement or any other easier method to do this, the help would be much appreciated :slight_smile:

This depends if you want the movement to be locked to one of the 6 axis directions (like kula world), or want truly free movement in any direction.

For free movement, you can use the camera’s transform.forward property, and move the ball along that. If you’re using physics, you could either apply a force in that direction, or if you want to apply torque you’d need to calculate the perpendicular vector to apply torque around. To do this, you’d use Vector3.Cross and feed in the camera forward vector and the relative “up” direction based on the current direction of gravity.

For movement locked to the 6 axes, you’d have to examine the values of the camera’s transform.forward property and see which of the x,y,z values have the largest absolute value (Using Mathf.Abs), then convert this into a normalized vector where the largest value is given a value of 1, and the others are zeroed.

Hope this helps!