# How to make an object follow the rotation of another object?

how to make an object following another object rotating around a circle?

So, object A stands still and rotates in a circular motion, right? Then you can just pass this object’s transform.rotation to the transform.rotation of the object that should follow it. If you only want to use the y rotation, then take the y value of the first object’s eulerAngles and pass it to the second object’s eulerAngles.

``````Transform object_a;
Transform object_b;

float euler_y = object_a.eulerAngles.y;
object_b.eulerAngles = new Vector3(object_b.eulerAngles.x, euler_y, object_b.eulerAngles.z);
``````

If the following object should rotate towards the edge of the circle, then you just take the first object’s transform.positon and add it’s forward direction vector times the radius.

``````Transform object_a;
Transform object_b;

Vector3 circleEdgePos = object_a.position + object_a.forward * radius;
object_b.LookAt(circleEdgePos );
``````

i am using this for the object_b, because i need controll mecanim velocity

``````void OnAnimatorMove(){

newPos = anim.rootPosition;
newRot= anim.rootRotation;

transform.position = newPos;
transform.rotation= newRot;
}
``````