'seeking' code

Get help using Construct 2

Post » Sat Oct 15, 2011 3:27 am

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?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Oct 15, 2011 9:20 am

[QUOTE=sqiddster] 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?[/QUOTE]

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
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sat Oct 15, 2011 10:56 am

Yeah, there is obviously that... but I was wondering if there was a way to pick the shortest way to go.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Oct 15, 2011 4:40 pm

Well, need more info. Shortest to what?
The usual detectors are overlapping at offset, and distance().
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sat Oct 15, 2011 10:13 pm

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.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests