# Camera/Direction Rotation

I know this probably is real noobish but I have a game where you roll a ball around using physics and I’ve been trying for weeks for when I rotate the camera (using the mouseOrbit script) to rotate the ball’s directions. For example whenever I rotate the camera the ball still moves in the same directions and it’s hard to move about. I’ve already tried using AddRelativeTorque which threw off the directions completely. The camera should always be facing forward in relative to the forward direction. Remember I’m using physics (AddTorque in direction).

var xSensitivity : float;
var ySensitivity : float;
var maxHeight : float;
var minHeight : float;
private var xPos : float;
private var yPos : float;
var myTrans : Transform;
var camTrans : Transform;

``````function Update()
{
yPos = Mathf.Clamp(yPos - Input.GetAxis ("Mouse Y") * ySensitivity, minHeight, maxHeight);
xPos = xPos + Input.GetAxis("Mouse X") * xSensitivity;
myTrans.rotation = Quaternion.AngleAxis(xPos, Vector3.up);
camTrans.localRotation = Quaternion.AngleAxis(yPos, Vector3.right);
}
``````

Put my Trans as your camera and the cam trans as the object you roll around. The camera should be in the ball too. Just drag and drop it in the place values and configure them. If this doesnt work then i have other worthy scripts. And the -75 was from people just -1’ing stuff. It’s funny really.

``````var torque = Vector3(Input.GetAxis("Vertical"), 0, -Input.GetAxis("Horizontal"));