- Home /
Priority Queue Code Problems
I've been searching around a lot for a way to use priority queues in JS, however I couldn't find anything. This is a pretty simple question but does anyone know how I can do declare and use a priority queue in Javascript?
That code is Javascript; Unity doesn't use that, it uses Unityscript (confusingly called Javascript, it's true). You'd have much better luck finding ActionScript 3 code or C# code and translating that to Unityscript.
No...as I said, find some other code and adapt it to Unityscript. You could adapt that Javascript code, for that matter, but it would be easier to adapt C# code. Or you can write your own; see Bunny83's answer.
Although, if you mean "is there any pre-existing Unityscript code for priority queues that I can copy and paste", then probably yes you are out of luck, or at least I don't know of any. (If you can use a plain old queue, rather than a priority queue, that's built in to .Net/$$anonymous$$ono so you can just use that.)
Well, I'm developing an A* pathfinding system and it works I'm just trying to optimize it as much as possible (without using C#). Are my other options better? If I have to use C# then can I write the AI code in C# but use it on my character who is coded in Unityscript?
Answer by Bunny83 · Aug 27, 2012 at 08:03 PM
If you talk about a priority queue in the usual sense, you can use a generic SortedList and specify a custom compare function, or implement the IComparable interface on your elements and provide your compare function there.
Your answer
Follow this Question
Related Questions
TouchPad in C# 3 Answers
Automatic fire in weapons 1 Answer
Help with using keys to activate scripts 2 Answers
Switching Between Weapons? 1 Answer
how alternate walk cycle javascript 1 Answer