One option, would be to create an empty game object to represent the center of rotation. You can child myGameObject to this “pivot point”. Then, simply Rotating “pivot point” will also move and rotate the child object.
Read the documentation for ‘Transform.RotateAround’:
If you first rotation something around the up axis, than right in world coordinates will not be the right of the object, but instead an axis off of the local right of your object by the amount of degrees you rotate around up.
This would mean, locally, it’d be the something like <0.9, 0, 0.1> or so (not really being perfect with those numbers). Which is 2 axes.
Try passing in the local up and right vectors of the transform:
lordofduct, thank you so much for pointing me in that direction. Using both GameObject directions gave me the exact same problem as before. But changing the UP direction to that of the GameObject and leaving the right alone fixed it.
Now the problem I’m facing is that when I try to do a rotation using the 3 axes there is also this problem between the 2 axes sharing the same space, and I don´t know how to fix this.
I came across this thread trying to tackle the same issue, I ended up moving the Y axis in world space, and the X axis in local space. With the Y axis constrained to world space the cumulative effect was gone. The last two lines are the relevant ones. Hope this helps
public class PodController : MonoBehaviour
{
float _horizontalSpeed = 2.0f;
float _VerticalSpeed = 2.0f;
void Update()
{
float h = _horizontalSpeed * Input.GetAxis("Mouse X");
float v = _VerticalSpeed * Input.GetAxis("Mouse Y");
transform.Rotate(0, h,0, Space.World);
transform.Rotate(v, 0, 0, Space.Self);
}
}