title: Java LWJGL - Monster not following me, runs between a bounds of 2
body: <p>I have written a script to be set off whenever a player is within a distance of the monster. The script checks if the x position is greater than or less than the players x, and same for the z. (y is automatically set to terrain)</p>
  
  <pre><code>public int checkWalkX(Vector3f position) {
      if (Math.floor(this.getX()) != Math.floor(position.x)) {
          if(this.getX() &gt; position.x) return 1; //Greater
          if(this.getX() &lt; position.x) return 2; //Less
      } 
      return 0;
  }
  public int checkWalkZ(Vector3f position) {
      if (Math.floor(this.getZ()) != Math.floor(position.z)) {
          if(this.getZ() &gt; position.z) return 1; //Greater
          if(this.getZ() &lt; position.z) return 2; //Less
      } 
      return 0;
  }
  
  public void follow(Player player) {
      walking = false;
      following = true;
  
      if(checkWalkX(player.getPosition()) == 1) this.setX(this.getX() - mobSpeed);
      else if(checkWalkX(player.getPosition()) == 2) this.setX(this.getX() + mobSpeed);
  
      if(checkWalkZ(player.getPosition()) == 1) this.setZ(this.getZ() - mobSpeed);
      else if(checkWalkZ(player.getPosition()) == 2) this.setZ(this.getZ() + mobSpeed);
  
      if(Math.floor(checkWalkX(walkToPosition)) == 0 &amp;&amp; Math.floor(checkWalkZ(walkToPosition)) == 0) following = false;
  }
  </code></pre>
  
  <p>For some reason when I run this script, the monster will only move within a distance of 2ish. He moves the right ways kinda, but he doesnt follow me. Would anyone know why this is?</p>