Rotating objects around other without rotating itself

Hi,

I’m having a death battle trying to rotate elements around another without rotating itself.

In a hex board, I’m trying to rotate the elements in the radius of an hex. I can do that with the transform.RotateAround() function, but I want to keep the local rotation of the radius object, so they don’t flip.

This is what I have now:

    void Update() {
    
    		if (pivot != null && selected != null) {
    			Debug.DrawLine((Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition), pivot.transform.position);

float pivotMouse = AngleBetweenTwoPoints((Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition), pivot.transform.position);
    			float pivotSelected = AngleBetweenTwoPoints(selected.transform.position, pivot.transform.position);
    			float difference = pivotMouse - pivotSelected;

Debug.Log ("Angle between pivot and mouse: " + pivotMouse);
    			Debug.Log ("Angle between pivot and selected: " + pivotSelected);
    			Debug.Log ("Diference: " + difference);

for (int i = 0; i < radius.Count; i++) {
    // This is the standard rotate around function, and goes perfectly, but as I said on the question, I don't want to change the local rotation of the object, just move around the pivot square
    radius*.transform.RotateAround(pivot.transform.position, Vector3.forward, difference);*
  •  	}*
    
  •  }*
    
  • }*
    Thanks everyone for your help!!

I just replied you and found the solution, but thanks anyway!

for (int i = 0; i < radiusGems.Count; i++) {
//radiusGems*.transform.RotateAround(pivotSquare.transform.position, Vector3.forward, angle);*

radiusGems_.transform.position = RotatePointAroundPivot(radiusGems*.transform.position,
pivotSquare.transform.position,
Quaternion.Euler(0, 0, angle));
}*_

public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Quaternion angle) {
_ return angle * ( point - pivot) + pivot;
* }*_