How do I Give AI to my enemy?

0 favourites
  • 12 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • So the game I'm making includes walls and the player and enemy have to be able to move around and my intention is to make it move around randomly and target the player once caught in sight. I already made player movements and stuff. PLease help me! (this isn't a platformer game and there are obstacles)

    Here are some pics

  • If this is platformer/side scroller game, this might fit your preference

    https://www.scirra.com/tutorials/1320/p ... enemies-ai

  • I forgot to mention it isn't a platformer..

    sgn15

  • Ok. I would suggest making sensors (invisible objects). Better yet, make different sensors for different movement directions.

    If enemy overlaps sensor_right, move right.

    If enemy overlaps sensor_left, move left.

    and so on.

    then you can also check line of sight or distance from player.

  • Ok, thanks, I never thought of that! I'll try it!

    sgn15

  • It didn't work out that well.

  • you might want to show a diagram or the screenshot of your layout because I don't know the theme/logic of your game

  • OK

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • sgn15

  • thomas Harding

    I can't make something out of those large pics. I mean just a simple diagram made from MS paint or a screenshot of your layout view in C2 would help explain what happens in your game (aside from what you have explained so far) since you said the sensors did not worked out so well. I don't know how you did it specifically.

    Aside from sensors, you can also check your distance (between player and enemies) as another condition for enemy AI.

    You might also want to use instance variables to store the direction an enemy is currently facing. So an enemy who is facing right that overlaps a sensor will go left, while an enemy facing right that overlaps sensor will go left. something like that.

    Try to summarize the things you want to take into account with in the AI mentally or in a piece of paper before trying to code them. Good luck.

  • Ok. I would suggest making sensors (invisible objects). Better yet, make different sensors for different movement directions.

    If enemy overlaps sensor_right, move right.

    If enemy overlaps sensor_left, move left.

    and so on.

    then you can also check line of sight or distance from player.

    This is very interesting. I think I can use this. Thanks!

  • It didn't work out that well.

    What is sgn15 is suggesting with the sensor points is quite clever. It should work very nicely if implemented correctly. I'll be trying this soon. Put the points along pathways and at intersections and turns. Add some logic in the points to intentionally direct certain sprites or even randomly turn them or make them act based on where they are or what they might have in LOS. It's a good idea.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)