How do I make paths in 45 degree increments?

Get help using Construct 2

Post » Mon Aug 10, 2015 1:29 pm

I've been using the pathfinding behavior and I'm unable to figure out how to restrict the path to only having 45 degree increments. I believe this is the Manhattan algorithm and can be easily implemented if this is an A* system. If I'm unable to do that then how would I be able to fake it? I've tried setting different 8 direction walking animations to an object depending on the angle of rotation the object actually using pathfinding is currently set to, but the results look like crap. For example if a sprite is animated to look like it's walking at 45 degrees but it's actually moving at a 60 degree angle across the screen it's obviously wrong and very noticeable.
B
6
Posts: 16
Reputation: 268

Post » Mon Aug 10, 2015 7:20 pm

You could try using a Between value condition to check the Sprite.Angle and then have it like:

if 44 < Sprite.Angle < 46
or
89 < Sprite.Angle < 91
or
134 < Sprite.Angle < 136
or
179 < Sprite.Angle < 181
or
224 < Sprite.Angle < 226
or
269 < Sprite.Angle < 271
or
314 < Sprite.Angle < 316
or
359 < Sprite.Angle < 361

then do movement

else do nothing (or maybe reorient the sprite using +/- degrees until it is in one of those avenues)
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Wed Aug 12, 2015 3:03 am

That doesn't work because if you use the movement I can't calculate how far I'm supposed to move it and then the game looks like it has extremely broken pathfinding.
B
6
Posts: 16
Reputation: 268

Post » Wed Aug 12, 2015 8:54 pm

Well put it on a looping check function and just adjust the degrees by like 0.1 or so. That way it will stop, do a slow turn until it is within the directional parameters and then move forward.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests