I'm making a 2.5 side scroll game. Game objects are 3D but the game is essentially 2D.
I have Ship B tracking Ship A's position along the x and y axis. When A moves past B in the side-scroll , I want B to Rotate around it's Y-axis as it is tracking A's movement.
I have script that does this but the Rotation around Z-axis is instantaneous. I need to slow it down to A's speed as it passes B from left to right. Sort of how an helicopter banks to make a turn. I don't need realism, Just need a smooth movement to show Ship B's 3D profile.
public class LookAtTarget : MonoBehaviour
{
public Transform target;
void Update()
{
float lockPos = 0;
{
transform.rotation = Quaternion.Euler(lockPos, transform.rotation.eulerAngles.y, lockPos);
}
if(target != null)
{
transform.LookAt(target);
}
}
}