• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Chimera3D · Aug 27, 2012 at 06:08 AM · javascriptsimplequeue

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?

Comment

People who like this

0 Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Chimera3D · Aug 27, 2012 at 07:38 PM 0
Share

So Javascript doesn't support priority queues?

avatar image Eric5h5 · Aug 28, 2012 at 02:34 AM 1
Share

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.

avatar image Chimera3D · Aug 28, 2012 at 03:16 AM 0
Share

Oh... that makes sense. So I'm just out of luck then?

avatar image Eric5h5 · Aug 28, 2012 at 03:43 AM 0
Share

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/Mono so you can just use that.)

avatar image Chimera3D · Aug 28, 2012 at 04:11 AM 0
Share

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?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Chimera3D · Aug 27, 2012 at 10:28 PM 0
Share

Look at my update first post.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spawn game objects on a timer 2 Answers

Quick Simple Coding Question 1 Answer

Overlap Detection HELP!! 0 Answers

Set Specific List Value 3 Answers

Talking Code 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges