I need only rotate the x-axis of an object to the mouse or touch, I’m currently using this code to rotate the object:
Vector3 screenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y);
screenPoint.z = -transform.position.z; //distance of the plane from the camera
dragObject.parent.LookAt(Camera.main.ScreenToWorldPoint(screenPoint));
But you change x, y, z axes, I want to change only x-axis, or convert the x, y, z in a single angle x. So with y and z to 0 degrees
Does anyone have the same problem and managed to solve it?
thanks in advance
Assuming it’s a 3D world, why aren’t you raycasting from the click position to an invisible plane and make it look at that point? This way, the plane defines the rotation.