# Why the transform is not moving back to the originPos(Original Position)?

using UnityEngine;
using System.Collections;

public class Move : MonoBehaviour
{
public Transform target;
public float rotationSpeed;
public float moveSpeed;

private Vector3 originPos;
private Quaternion originRot;

private void Start()
{
originPos = transform.position;
originRot = transform.rotation;
}

private void Update()
{
var distance = Vector3.Distance(transform.position, target.position);
if(distance < 0.1f)
{
transform.rotation = Quaternion.Lerp(transform.rotation, originRot, Time.deltaTime * rotationSpeed);
transform.position = Vector3.MoveTowards(transform.position, originPos, Time.deltaTime * moveSpeed);
}

transform.rotation = Quaternion.Lerp(transform.rotation, target.rotation, Time.deltaTime * rotationSpeed);
transform.position = Vector3.MoveTowards(transform.position, target.position, Time.deltaTime * moveSpeed);
}
}


At this line if the distance is less then 0.1f it should start moving back to the original position but the transform is not moving it's just staying at the same place :

transform.position = Vector3.MoveTowards(transform.position, originPos, Time.deltaTime * moveSpeed);


The moment distance < 0.1f is true, it will indeed start moving back to its origin. However, this will make the comparison untrue again, putting it back on its original trajectory.