0 Favourites

'seeking' code

  • Hi, everyone.

    I have tried out Kyatric's great pathfinding algorithm, however it is proving a bit unsuitable for my purposes, for a variety of reasons.

    I have decided to write a very basic 'pseudo' pathfinding code for my purposes.

    The game is a top down based game, with enemies supposed to be seeking the player. The walls are a constant width and do not have any T or X intersections, just bends and straights.

    This is what I am thinking.

    1. Every tick: enemy move at angle towards player (so enemy does not have to turn, don't ask ;) )

    2. If enemy hits wall, move along the wall until there is an oppurtunity to move directly towards the player. go to step 1.

    I am not sure how to implement this within the program, any help? Also, if there is any way to determine which way the enemy will follow the wall in Step 2, that would be great. Perhaps using invisible collision objects?

  • Also, if there is any way to determine which way the enemy will follow the wall in Step 2, that would be great. Perhaps using invisible collision objects?

    You can choose left or right randomly. Like if random(2) = 0 set angle to .angle +90, if random(2)= 1 set angle to .angle -90

  • Yeah, there is obviously that... but I was wondering if there was a way to pick the shortest way to go.

  • Well, need more info. Shortest to what?

    The usual detectors are overlapping at offset, and distance().

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Anyway, this is not the main issue, just a sidenote.

    The main problem is how to get the enemy to follow a wall while checking if it has a free run to its target.

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