- Home /
Implementing Dijkstra's Algorithm in UnityScript
Hi,
I'm working on a turn-based tactics game in which the action takes place on a 2D grid. (I should probably mention that this is my first major Unity project.) I'd like to use Dijkstra's algorithm for finding the movement and attack ranges of units in Manhattan distance. However, Unity doesn't appear to support some of the data structures I need for this implementation (specifically priority queue, map, and list types). What are the best ways to resolve this?
Right now, I'd like to import standard JavaScript library implementations, but it doesn't seem like that's possible. I might be overlooking something really obvious, but as far as I can tell so far, Unity isn't compatible with standard JavaScript. My background is in design and not engineering, so I'm not too enthusiastic about having to write efficient custom implementations of these. Any recommendations? Thanks in advance.
http://msdn.microsoft.com/en-us/library/0sbxh9x2.aspx It would be much easier to port C# code to Unityscript than Javascript code.
Answer by tingham · Feb 06, 2012 at 02:13 AM
You might want to check out the source for Three.js Many of the algorithms can be ported over to Unity by simply fixing the namespace of the class references and function names.
If nothing else you could probably prototype your game in WebGL using Three.js and then work backwards porting in to unity from there (if it's even required.)
Well, one of the main reasons I'm using Unity for this project was to be able to prototype in-engine. I'm also not seeing the classes I'm looking for in Three.js, although it's got enough source content that I might be overlooking them somewhere, or not recognizing them. Thanks for the recommendation though.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Call the same function on different scripts. 1 Answer
What can i do? Unity no responding when i load a list. 1 Answer
null reference exception problem with generic lists in unityscript (i think...) 1 Answer
Is there a way to convert a 2d generic list to a string in unityscript 1 Answer