world direction to local when instantiating

Hi! I am trying to get some 3d menu going.
I have found a script that does what i want - instantiate object around center in circle:

if(Input.GetKeyUp(KeyCode.LeftAlt))
{
	
	    var center = my3dCamera.transform.position;

   		for (i = 0; i < 5; i++)
   		{
        var pos = RandomCircle(center, 2);
        
        // make the object face the center
        //var rot = Quaternion.FromToRotation(Vector3.forward, center-pos); //not needed
        var clone = Instantiate(button, pos, transform.rotation); //rot
    	}
}

function RandomCircle(center:Vector3, radius:float): Vector3 {
// create random angle between 0 to 360 degrees
var ang = Random.value * 360;
var pos: Vector3;
pos.x = center.x + radius * Mathf.Sin(ang * Mathf.Deg2Rad);
pos.y = center.y + radius * Mathf.Cos(ang * Mathf.Deg2Rad);
pos.z = center.z;
return (pos);

}

i have attached this script to main camera.
Problem is that i cant get my camera local direction. center variable is always pointing in the world rotation(or direction). How can i pass “center” to RandomCircle function in it’s (camera this script is attachet to) local direction?

I have tried transform.localRotation, transform.TransformDirection, InverseTransformDirection, but nothing works. They are instantiated off screen, but always facing world coords.

Try this-

var pos =  my3dCamera.transform.TransformPoint(RandomCircle(center, 2));

And then after you’ve instantiated the cube to rotate it so it faces the camera, use

clone.transform.LookAt(my3dCamera.transform);

This way, your circle will align with the camera’s local axes, and the cubes will face the camera.