Transform.RotateAround is incorrect answer, because it adds value to existing rotation.
Alright, so here is my solution. In reality, RotateAround() could still be useful to you. You can solve your problem by creating a function called “Rotate” for example with a float parameter called “literalAngle”. This parameter would be the angle you want your B object to have. In the actual function, you would use RotateAround() function and in the angle parameter, you would negate “literalAngle” with the x euler angle of the B object. Here’s a snippet which should explain better what I mean:
public GameObject centre;
void Update () {
if (Input.GetKeyUp(KeyCode.Space))
{
Rotate(54);
}
}
void Rotate(float literalAngle)
{
transform.RotateAround(centre.transform.position, -Vector2.left, literalAngle - transform.eulerAngles.x);
}
The script in which this code is found in should be attached to the B object and you should also drag the A object in the “centre” variable from the Inspector. When you play, press space to rotate the object to the desired angle. If you press again, nothing would happen as since the x-angle and the literAngle are the same, the rotation would result to 0. Hope this helps! And if it did, kindly mark as correct.