Mouse click pathing & obstacles
by Brian Carter · in Torque Game Builder · 03/15/2008 (4:48 pm) · 5 replies
Does anybody know of any examples, or any references to algorithms, that show how to go about incorporating mouse clicked movement between two points with an obstable in the way?
i.e
(A) || (B)
Player is at point A, clicks the mouse on point (B). Player A starts walking to point (B) but encounters an obstacle and has to path around it. Its the pathing around obstacles that I need to know how to do. Going from point A to B in a straight line with no obstacles is not a problem, nor is getting the input event from the mouse.
Anybody?
i.e
(A) || (B)
Player is at point A, clicks the mouse on point (B). Player A starts walking to point (B) but encounters an obstacle and has to path around it. Its the pathing around obstacles that I need to know how to do. Going from point A to B in a straight line with no obstacles is not a problem, nor is getting the input event from the mouse.
Anybody?
#2
03/16/2008 (5:13 am)
I'm ok with coding, I've got around 20 years of C++ coding under my belt, unfortunately that has been related to client server architectures in the financial sector. I just wasn't sure on what this behavior was called in the gaming circle, but "A*" pathing answers my question thankyou - it at least gives me a spring board to launch further research from.
#3
www.gamedev.net/reference/articles/article2003.asp
It's exactly what I was looking for, and is a good resource for anybody wanting to do the same thing.
Edit: The above article also links to a sub article that would be good for anybody considering this type of system for an isometric game (which is what I'm actually doing), and can be found at www.policyalmanac.org/games/twoTiered.htm
03/16/2008 (5:26 am)
Did a search on "A*" Pathing and came up with this link that somebody else posted:www.gamedev.net/reference/articles/article2003.asp
It's exactly what I was looking for, and is a good resource for anybody wanting to do the same thing.
Edit: The above article also links to a sub article that would be good for anybody considering this type of system for an isometric game (which is what I'm actually doing), and can be found at www.policyalmanac.org/games/twoTiered.htm
#4
@Lance, thank you for the pointer in the right direction. Now I just need to optimize it and add in terrain influences and risk influences.
03/16/2008 (8:09 pm)
I just managed to get basic A* pathing working as per the reference article above.@Lance, thank you for the pointer in the right direction. Now I just need to optimize it and add in terrain influences and risk influences.
#5
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9711
I have integrated this code into a test project and its almost working. The example project it comes with works perfectly however, and provides a big "wow" factor, debugging rendering etc..
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10616
This seems to be a torquescript only ( no C++ ) version of Astar pathfinding. Which sounds insane to me for performance reasons but definitely worth checking out.
03/22/2008 (1:35 pm)
Definitely check out these two resources if you are working on AStar in TGB:www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9711
I have integrated this code into a test project and its almost working. The example project it comes with works perfectly however, and provides a big "wow" factor, debugging rendering etc..
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10616
This seems to be a torquescript only ( no C++ ) version of Astar pathfinding. Which sounds insane to me for performance reasons but definitely worth checking out.
Torque 3D Owner Lance Hampton
You'd probably be looking for "A*" pathing.
If you're not a serious coder and you can't find one easily, I'd suggest faking it. When player is as A and clicks on B, check if the path is clear. If not, don't allow that as a click. This means going around a corner would mean clicking once at the end of a hall and then again after the corner has been cleared. You could even set up a series of waypoints like this pretty easily (maybe right click or click on the character to erase or stop).
How about some background? Are you using tiles? open areas with ImageObjects blocking?