I have a third person camera that can orbit around the player and(when needed) reposition and lock itself behind the player for targeting purposes. I want to make it so when switching from targeting to orbit the camera will keep the position and not snap back to the orbit position it had.
void UpdatePosition()
{
if(!Targeting2.Instance.isTargeting)
{
var posX = Mathf.SmoothDamp(position.x, desiredPosition.x, ref velX, X_Smooth);
var posY = Mathf.SmoothDamp(position.y, desiredPosition.y, ref velY, Y_Smooth);
var posZ = Mathf.SmoothDamp(position.z, desiredPosition.z, ref velZ, X_Smooth);
position = new Vector3(posX, posY, posZ);
transform.position = position;
transform.LookAt(TargetLookAt);
}
else if(Targeting2.Instance.isTargeting)
{
var posX = Mathf.SmoothDamp(position.x, desiredPosition.x, ref velX, X_TSmooth);
var posY = Mathf.SmoothDamp(position.y, desiredPosition.y, ref velY, Y_TSmooth);
var posZ = Mathf.SmoothDamp(position.z, desiredPosition.z, ref velZ, X_TSmooth);
position = new Vector3(posX, posY, posZ);
transform.position = position;
transform.LookAt(TargetLookAt);
}
}
Can't you just save the position to a variable, and then when you need to snap back just set the position to the variable.
– dendens2