Position change detection

How to make script that detect if there any change in position of player or entity ?

How about checking if the position has changed?

Vector3 lastPos = Vector3.zero;
bool hasChanged;
float delta = 0.1f;
bool CheckIfChanged ()
{
   if (Vector3.Distance(player.transform.position, lastPos) > delta){
      hasChanged = true;
     lastPos = player.transform.position;
   }
   else
   {
      hasChanged = false;
   }
   return hasChanged;
}
1 Like