Platformer Enemy

AngelDog

  • Posts: 37
I am completely finished with my game except for enemies. In the end, I just need one type and two boss things. I've figured out health by myself, but at least it was simple, just -1 of health when hit.

But for the life of me, I cannot figure out how to make an enemy that can move left and right and shoot at the player, maybe follow them a bit. One of the bosses just needs to go after the player while taking damage from them.

Someone please help me out with this so I can put the game up! I'm pretty sure I could've had this game out a year ago without this roadblock.
beep bop

johnjanowskibsc

  • Posts: 158
Have you experimented with any of the behaviours?

Would the follow target behaviour work?


JeffreyDriver

  • Posts: 2262
There's the easy math extension that may be of some help as it lets you easily get values such as the distance between two actors.

http://community.stencyl.com/index.php/topic,27769.0.html

Moving an enemy shouldn't be too difficult.  You can check if the player is to the left or right of an enemy by comparing the x-center values of each. Then if the player is within a certain distance,  get the enemy to move horizontally towards the player.

Checking and comparing the y-values you can see if the player is within line of sight. If so, shoot towards the player.

Finally, if you don't want your enemies to fall off platforms, you need to check if a tile doesn't exist in front of the enemy. So when it finds a gap, it stops moving. You can do the same to stop it if there's a wall in the way. Just check if there is a tile in the way.

AngelDog

  • Posts: 37
Have you experimented with any of the behaviours?

Would the follow target behaviour work?



Yeah, I messed with behaviors. Follow target acts like it's a top-down game, so the enemy floats toward the player like so.
beep bop

AngelDog

  • Posts: 37
There's the easy math extension that may be of some help as it lets you easily get values such as the distance between two actors.

http://community.stencyl.com/index.php/topic,27769.0.html

Moving an enemy shouldn't be too difficult.  You can check if the player is to the left or right of an enemy by comparing the x-center values of each. Then if the player is within a certain distance,  get the enemy to move horizontally towards the player.

Checking and comparing the y-values you can see if the player is within line of sight. If so, shoot towards the player.

Finally, if you don't want your enemies to fall off platforms, you need to check if a tile doesn't exist in front of the enemy. So when it finds a gap, it stops moving. You can do the same to stop it if there's a wall in the way. Just check if there is a tile in the way.

I'll work with this information and see where I can get, thank you.
beep bop