try using x+= or x-= for movement, and blockers to make the enemy change directions. or you could make it so they move only if their within a certain range of the character:
- Code: Select all
if(player.x<x&&player.x>x-200)
{
x-=1;
}
that would make the enemy move left if the player is on its left and within 200 pixels on its left.
- Code: Select all
if(player.x>x&&player.x<x+200)
{
x+=1;
}
that would make the enemy move right if the player is on its left and within 200 pixels on its right.
to create an enemy, just clone it. with the collision destroy things, try making them on the enemy's and leaving it as "Event Actor"that way it only destroys the actor whos event it is, so the one which is colliding. create enemys also by using the create actor event and colliders.
have a canvas, then when the player touches it, it makes an enemy say... 300 pixels to the right of it. that way it is made at the right time.