so are you doign this as 1 rotation or 3? (a realistic turret for example would use 3 seperate axes to move to it, a spaceship with RCS thrusters would find the axis of rotation and apply a single rotation along that axis)
Spaceship
StartVector = AIM_AT.transform.forward;
EndVector = (AIM_AT.transform.position - POINTING_OBJECT.transform.position).normalized;
AXIS_TO_ROTATE_ON = vector3.cross(EndVector,StartVector);
//angle is FYI you may not actually require this bit of information
ANGLE = Mathf.Atan2(Vector3.Magnitude(AXIS), Vector3.Dot(Startvector, EndVector));
so now your just going to rotate along
I assume you know how to do the calcuations for 3 axis (just ignore an axis each time and find each 3)
If your issue is how do i start and stop the rotation.
well you simply apply torque along the axis which is what we computed above
so
.addrelativetorque(AXIS_TO_ROTATE_ON * speed)
so now we have it rotating properly on that axis
now comes another decision
do you want a constant turn rate with a sudden stop or a kind of curve where you approach it and gradually settle on your target.
if you want a sudden stop just do a
//bear in mind doing vector3 == vector3 isn’t actually dead accurate, answers taht are close but not exact work, FOR FLOATING POINT NUBMERS and vector3 is 3 floating point numbers floatinga == floatingb acutally means is floatinga APPROXIMATELY floatingb
this actually is ok though, you cant hit it aiming perfectly in a frame nessacarily but if your really close to aiming at it it’ll trigger the stop.
if(transform.forward == EndVector)
{
//apply a counter torque so get the current torque and apply that exact same amount of force on the -axis
}
if you want to gradually approach you can use a lerp/slerp
you can also use the angle caclatuion above or vector3.angle (might not work as well)
to basically take the angle and be like as the angle approaches 0 speed used in addrelativetorque appraoches 0.
anyways there are some ideas.