function Gunner3:Create(me)
	SetHealth(me,8)	
	SetPower(me,0)
	ChangeAnimation(me,"Stand")
end

function Gunner3:Update(me)
	DebugNumberQuery(me, -3)

	if IsPlaying(me,"Stand")
	then
		DebugNumberQuery(me, -2)

		local playerX = GetPlayerX(me)
		local playerY = GetPlayerY(me)

	
		local playerDistance = PlayerDistanceX(me,playerX,playerY)

		if playerDistance <= 300
		then
			DebugNumberQuery(me, -1)

			state = GetPlayerState(me)

			if state == 5
			then
				DebugNumberQuery(me, 0)

				local myX = GetPosX(me)
				local myY = GetPosY(me)

				self.targetX = playerX
				self.targetY = playerY + 30

				if self.targetX > myX
				then
					SetDirection(me, 1)
					self.targetX = self.targetX - 48.0;
				else
					SetDirection(me, -1)
					self.targetX = self.targetX + 48.0;
				end

				DebugNumberQuery(me, self.targetX)
				DebugNumberQuery(me, self.targetY)

				ChangeAnimation(me,"Walk")
			end
		end
	elseif IsPlaying(me,"Walk")
	then
		DebugNumberQuery(me, 1)

		local distToTarget = DistanceToTarget(me,self.targetX,self.targetY)

		if distToTarget >= 6
		then
			DebugNumberQuery(me, 2)

			if ApproachTarget(me, self.targetX, self.targetY, 20.0) == false
			then
				self.targetX = GetPosX(me)
				self.targetY = GetPosY(me)
				self.doWalk = false
			end
		else
			DebugNumberQuery(me, 3)

			SetVelocity(me,0,0)

			ChangeAnimation(me,"Attack")
		end
	elseif IsPlaying(me,"Attack")
	then
		DebugNumberQuery(me, 4)

		if HitFrame(me,1)--EndOfAnimation(me)
		then
			DebugNumberQuery(me, 5)

			child = CreateObject(me,"ColliderDownF","EnemyWeapons", 0,0,1,false)
			SetPosition(child, GetPosition(me))
			SetDirection(child,GetDirection(me))
			OffsetObject(child,50*GetDirection(me),0)

			ChangeAnimation(me,"Stand")
		end
	end
end