title: How to make an enemy follow a certain path
body: <p>How do I make my enemy follow a certain path? This is all I have right now, I'm using Tiled for the images and such. I'm trying to make a game where the player enters an area, and has to avoid the enemy to get the coin so the door will open to the next area. But because my enemy is patrolling the enemy sometimes enters the hallway to the next area and that's not supposed to happen obviously.</p>
  
  <p>I also had a problem with the door, it doesn't disappear when I pick up the coin. I thought that the easiest way to do this is that when I reach a certain score, the door is removed, but it doesnt disappear until the player touches the door. Any suggestions? Maybe link the coin with the door so that when it's picked up, they both disappear somehow?</p>
  
  <pre><code>Level.Load ("Game.tmx")
  player = {
    object = nil,
    score = 0,
    health = 100,
    speed = 3,
   }
  
  function Start()
    --Identify the objects, naming them
    player.object = Level.GetObject ("Player")
    enemy = Level.GetObject ("Enemy")
   -- music = Sound.Load ("music.mp3", true, true)
    Hud.Message ( " Start ", 2)
  end
  function DoPlayer()
    player.object = Level.GetObject( "Player")
  end
  function DoEnemey()
    enemy = Level.GetObjects( "Enemey" )
  end
  function DoSign()
    Sign = Level.GetObject( "Sign" )
  end
  function DoDoor()
    door = Level.GetObject( "door" )
  end
  
  function Update()
    --HUD
    Hud.Score ("Score : " ..player.score )
    Hud.Health ("Health : " ..player.health )
  
   --Controllers 
  Controller.Wasd (player.object, player.speed)
  Controller.Patrol (enemy, 2)
  Camera.Follow (player.object)
  
  end
  
  function info()
    Hud.Message ("Pick up coins to proceed to the next area!", 3)
  end
  function CoinPickup( target, source)
  
    if target == player.object then
      player.score = player.score + 1
      Level.RemoveObject( source )  
    end
  end
  
  function DoorOpen( target, source)
    if target == player.object
     and player.score == 2
      then Level.RemoveObject ( source )
      end
    end
  </code></pre>