Grid based pathfinding using RTS behaviour

Post your own tutorials, guides and demos.

Post » Sun Jul 18, 2010 10:42 pm

I see Toralord beat me to it with this one but this is my take on grid based pathfinding.

Wot I did was:
Use the Hunter sprite with the RTS behaviour and changed the settings so it could not move but would point in the right direction based on whatever path it has determined.
Always set its position to Hunter2 which has the grid behaviour
Then, depending on the Hunter's RTS direction, changed the angle of Hunter2 and let the grid movement do its thing. Technically you probably shouldn't even need to change Hunter2's angle or worry about whether or not it is blocked or most of the other checks you see in the code but I would prefer that the pathfinding spaz out and not move than end up in a solid object.

Piece of cake.
B
4
S
1
G
3
Posts: 10
Reputation: 1,070

Post » Mon Jul 19, 2010 4:41 am

the reason I don't use the RTS behavior is that it is not accurate enough for gird based movement.
when I first started making a turn based strategy game I started with the RTS behavior and found out the for very slow speed it work okay but the faster you set the speed of the sprite the more the bad accuracy became apparent. I assume that is why you added the ever millisecond 500 condition. I also realized the RTS behavior recalculate every tick which is great for RTS game but not for TBS.
with all that being said, I love the simplicity of this cap. great job :!:
B
21
S
4
G
4
Posts: 280
Reputation: 2,934

Post » Mon Jul 26, 2010 1:11 am

If the RTS behavior could limit itself to certain kinds of objects or families for its travel, rather than just avoid them, I would probably use this exact approach myself. It's incredibly handy and consise, the way you've done it!

As it stands, I'm trying to solve basically the opposite problem, which turns out to be a bit more work. This is a nice bit of inspiration, though (yours too, toralord). :)

Oh, just one little suggestion: Movement's a bit smoother if you change out the "Every 500 milliseconds" condition for "If != Hunter 2 is moving". Assuming you don't want the pauses, anyway.
B
2
S
1
G
2
Posts: 48
Reputation: 896

Post » Thu Jul 12, 2012 12:04 pm

Nice soultion!

How would you set it up when you have multiple "hunters"(enemies)?



B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Sat Jul 14, 2012 11:48 am

Can anyone help me out on this one? Please... ;P


Here is the link to the original cap
Old cap
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Wed Dec 03, 2014 7:42 am

no problem man 8-)
You do not have the required permissions to view the files attached to this post.
B
5
S
2
Posts: 2
Reputation: 517


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests