• 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
0
Question by Aram-Azhari · Mar 19, 2013 at 09:30 AM · simulationtraffic

Handling large scale data for traffic simulation

Hi,

We are trying to find the most suited game engine for simulation of large scale data of traffic.

Formerly, I tried a similar simulation to update thousands of objects that belong to pollution and it didn't work very well. The thing is, the update function would bring the frame rate to 2 fps which wasn't really optimal.

so the question is, can we use Unity to update car movements (more than 200 cars at a time) while trying to feed around 1,000,000 float numbers to the system for calculation?

Any thoughts on this would be great.

Thank you.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tarlius · Mar 19, 2013 at 09:49 AM

The real question is do you need to do ALL that data every frame? Most games of this kind will be doing a lot of faking behind the scenes.

If even after optimising the code its still too slow (and since you say 1,000,000, I would guess unity [and any game engine] will be too slow), you'll want to consider making the process yieldable and processing the variables over a series of frames.

If desperate for speed, you might be able to feed the data into a shader and do it on the graphics card, since this sort of computation will probably be very suited to parallelisation.

Updating the positions of 200 cars in real-time, on the other hand, should be trivial.

Comment
Add comment · Show 9 · 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 Aram-Azhari · Mar 19, 2013 at 09:58 AM 0
Share

The problem is, this is a serious game. It cannot have fake calculations/interpolations. And it is a real-time system, that means showing the solution has a deadline.

I can understand that making calculations on another thread will be wise. The problem I was facing in the pollution simulation was that I had to update 9600 gameobjects in matters of rotation and color. I had to read the values from an excel file (which takes a very very very long time) and then update the objects that was also an slow task.

This time, I don't even have the data available offline. I will receive the data through a service (perhaps a web service) and then I need to update them.

Any techniques that you may have in $$anonymous$$d or that you may be able to refer me to?

Thanks.

avatar image Tarlius · Mar 19, 2013 at 10:27 AM 1
Share

I think you'd be hard pressed to get that much information through the internet 60 times a second anyway (1$$anonymous$$ floats is about 4$$anonymous$$B (32bit x 8bits to a byte/1024 kb to a byte = 3900$$anonymous$$B), you'd probably only send what has changed, which you would be able to apply to the local model much more quickly than a complete rebuild.

What exactly do you mean by "serious"? The image I have in my head is like sim city/etc. I can't imagine why you would have to update it the same frame you got it is all, would the user really know/care? I remember pollution data/etc in simcity taking a few frames to update. In fact, updating it instantly could even be less realistic, since destroying that coal plant won't instantly remove all the pollution anyway.

But as I said, if you really need blistering speed, I'd suggest looking at writing a shader to do it. I've never done it myself, but if the data can be crunched in parallel, I would imagine thats the fastest way to do it. But also probably the most difficult.

Another "trick" that might be relevant to you is only simulating what the player can actually see.

avatar image Aram-Azhari · Mar 19, 2013 at 10:37 AM 0
Share

Thank you.

I think I should localize the processing of the data as well as its visualization so only the visible portion is updated, although the simulation requires the whole world. The 1$$anonymous$$ floats is taken only once every second, but it is to be updated around 15 times within unity. The initial data that comes from the service is only to resynchronize any miscalculation to the correct ones.

What I meant by serious is as mentioned in Wikipedia

Simcity is a great game, but it doesn't involve real data of an actual city to control the traffic.

avatar image Tarlius · Mar 19, 2013 at 10:59 AM 0
Share

If you are going with a client-server model, perhaps you could do the actual simulating on the server and send the client only the pieces they need? The best strategy will depend on the type of game you're making of course.

Sounds like a pretty cool project anyway :) I'd love to work on some detailed simulation stuff :(

avatar image whydoidoit · Mar 19, 2013 at 11:22 AM 1
Share

Just FYI:: for your 9600 object earlier case then your best bet for a large number of rigid objects is probably to combine them into a skinned mesh and move them using the bones of that mesh (each object gets one bone)- this uses much less memory than having a large number of game objects hanging around with renderers etc. The limitation is that they must be opaque objects as draw order is not guaranteed and depth buffering is required to make it look right and that in cases where you can only see a few it will still have roughly the same performance as when you could see all of them).

This involves writing a shader, also you would normally want to use a limited number of meshes and have the shader work out how to recolour objects so that they look different by using a reference texture for the color tint, although you could also use procedural vertex colors.

Show more comments

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

12 People are following this question.

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

Related Questions

How can I make simple traffic lights? 0 Answers

Creating Simulator Quick and Fast 1 Answer

Interactive Cloth - Mobile? 1 Answer

Networking for send command (string, float, boolean, int) 0 Answers

Ripple simulating shader on irregularly shaped objects 1 Answer


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