Cant Make AI Chase Player!

0 favourites
  • 12 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello there,

    I have an issue that i need fixed. I'm making a game that i think would be really cool but i cant execute it! I'm fairly new to Construct 2 and I just bought it so I know pretty much nothing . So I need to make the AI or Enemy chase the player when in range ( Ive already made it turn towards the angle of the player but the LOS is indeed broken.... So I cant figure out why the AI wont go after the player? Any help would be nice!

    Thanks in return AfterLifeGames!

  • Giving some more info about how your game works, or even better, posting a capx file that includes the part that you want us to help you with, could be very useful to the rest of us, in order to help you.

  • Giving some more info about how your game works, or even better, posting a capx file that includes the part that you want us to help you with, could be very useful to the rest of us, in order to help you.

    So I figured out how to make the AI chase the player but the AI wont wander aimlessly around the map! Also no matter where i am in the layout it will find me is there anyway that i can make it to where only a certain distance or if i can only be seen where the AI is looking?

    and i dont know how to post CAPX file on here.... :3

  • You can host your capx file on a site like zippyshare or dropbox , then post link here. Also how is your friend the Fa$$ot when you were looking for his boner?

  • LOS sometimes has its own mind or breaks.... instead of LOS you can use the system expression compare two variables and calculate the distance as this :

    distance(ai.x,ai.y,target.x,target.y)<100 ---->actionfor AI sprite{set angle towards position (target.x,target.y) } / action2 for AI sprite{ moveforward 2px+(60*dt)............}

    the 100 acts as the visibility... however this has no view cone as los has its automatically 360 view.. so even if you come from behind it... will still follow the player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LOS sometimes has its own mind or breaks.... instead of LOS you can use the system expression compare two variables and calculate the distance as this :

    distance(ai.x,ai.y,target.x,target.y)<100 ---->actionfor AI sprite{set angle towards position (target.x,target.y) } / action2 for AI sprite{ moveforward 2px+(60*dt)............}

    the 100 acts as the visibility... however this has no view cone as los has its automatically 360 view.. so even if you come from behind it... will still follow the player.

    So essentially I cant make it where the enemies view is the only way i can be found and i was thinking of making it where i could backstab the enemy sneakily and that would be the only to kill them

  • So essentially I cant make it where the enemies view is the only way i can be found and i was thinking of making it where i could backstab the enemy sneakily and that would be the only to kill them

    You could have an AND event added to visibility that checks player position relative to AI position, rotation would affect where the player is "unseen".

  • So essentially I cant make it where the enemies view is the only way i can be found and i was thinking of making it where i could backstab the enemy sneakily and that would be the only to kill them

    well you can, you basically can reproduce the LOS behavior by event sheet, the code i gave as a example is only measuring the distance to trigger the follow action.

    For "visibility" or cone view effect, you need to calculate the direction the AI is facing... however it might be you are using LOS wrong and thats why it breaks. take a look at the RTS example in the default templates of C2 that might help you understand better the LOS usage.

  • You could use Turret behaviour combined with LOS.

    The LOS looks if the player can be seen, accounting for obstacles. Not seen = dissable the turret.

    The turret takes care of the angle (only rotates when the player is in range), take care of choosing the moment that it will run to the player (when it has a target), knows at wich angle to move towards the player.

    Or LOS combined with Pahfinding.

    Attach a invisible object to the nose of the player. Give it a high Cost. Now the Pathfinder wil prefer the back of the player for aproaching.

  • Here is a basic solution using the pathfinder plugin, in combination with the Line of sight plugin. I haven't implemented any backstabbing logic, but the enemies try to follow you if they have a direct line of sight and you are within their viewing distance.

    https://www.dropbox.com/s/5fnknrr5b79svra/AI.capx?dl=0

  • Exactly dear

  • Here is a basic solution using the pathfinder plugin, in combination with the Line of sight plugin. I haven't implemented any backstabbing logic, but the enemies try to follow you if they have a direct line of sight and you are within their viewing distance.

    https://www.dropbox.com/s/5fnknrr5b79svra/AI.capx?dl=0

    Thank you soooo much!

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