'seeking' code

0 favourites
  • 5 posts
From the Asset Store
Two levels with two sistem Wave. with Source-code (.c3p) + HTML5 Exported.
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, need more info. Shortest to what?

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

  • 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)