# (unity) Quaternion.RotateTowards doesn't seem to work as I imagine it to?

Given point A, given a transform with an arbitrary forward (it can turn), and given the starting position of an object anchored at point A, I want to rotate that object away from the forward. I googled around and found Quaternion.RotateTowards, which seemed right:

Object.MoveRotation(Quaternion.RotateTowards(Quaternion.Euler(Object.x, Object.y, Object.z), pointA.rotation, x));

But after testing it out, it doesn't actually do what I want it to do, the resulting angle changes according to how bit x is, if it's close to zero, it basically becomes the same as the original Object.x, if it's positive high, it replicates the forward, if it's negative, it seemingly goes randomly. Am I using it correctly?

Is there an easier way to achieve something like this?? (In 3D, not 2D)

## Comments

Transform.LookAt()– Points the Z-axis at a position in world spaceQuaternion.LookRotation()– Points the Z-axis in a directionQuaternion.SetFromToRotation()– From one direction to anotherQuaternion.RotateTowards()– Match rotationIt sounds like you want Quaterion.SetFromToRotation?

Also, I'm unsure of what the "to" direction is, and therefore I thought RotateTowards would work as it is theoretically "rotate towards a target but stop when you've rotated x degrees", which seems like what I want. I don't know the exact target but I do know the target I want to rotate towards and how many degrees i want to rotate it towards by (not all the way).

Of course if Object's pivot was at point A to start with then it does not need to have the parent to act as anchor.

But maybe I am not understanding the question correctly.

So you can get the world rotation to your target with:

Quaternion Rot = Quaternion.LookRotation(Target.position - transform.position, Vector3.up);

then alter the rotation using something like:

Quaternion Offset_Rot = Rot * Quaternion.euler(0f,somedegreesinY,0f);

@Blackson I know the target's physical location in space that I want to rotate towards, not sure if that's what you mean?

I can't just pick one set of degrees and ignore X and Z as I'm moving in 3D space and not just 2D.

nvm, I see you made a new post with more info about this.

Quaternion TargetRot = Quaternion.LookRotation(Target.position - transform.position, Vector3.up);

(that gives you the final target rotation)

Then lerp the rotation of the object that must look with:

transform.rotation = Quaternion.Lerp(transform.rotation,TargetRot,Time.deltatime*rotation speed);