- Home /
Is it recommended to do scientific modelling in unity or should i write a standalone program
Hello Unity community,
At this moment i'm researching the possibility to simulate a technical process in unity. This process is about collisions and the plastic and elastic deformations this brings into a model. Since i want to use different models i thought that maybe unity could come in handy for my project so i can load different models into unity. I am aware that the unity physics engine is not capable of calculating the plastic deformation after collisions so my question is is it still an advantage to use unity or should i write a seperate program to develop a simulation. I'am a software engineer so wrtiting a seperate program wouldn't be a problem either. I just want to know if unity can bring any advantages for my purpose or if it will bring disadvantages if used.
thanks in advance
Answer by meat5000 · May 13, 2016 at 11:10 AM
I would not advise Unity for scientific modelling. For illustration of a scientific concept is another matter.
Unity3D is designed to be efficient for making games which means there are a lot of cutbacks in terms of accuracy and function in order that it is optimised for making a game run. For example Floating point error is actually quite high and the degree of accuracy is really low compared to a Modelling tool such as MatLab.
A lot of the physics simulation in Unity is Visually oriented. This means that it is not too important on a procedural level as long as the Visual outcome is smooth and looks within the realms of plausibility. The Engine itself commands tick-rates etc and so a Physics simulation can be subject to varying timesteps, which is obviously the opposite of what is needed for modelling in a scientific way.
Unity3D's implementation of PhysX does not allow you access to the PhysX API. The rigidbody implementation (and other things) were created using the PhysX API and the Final Result is what is included in the Unity engine, so its a hard coded implementation and is not subject to any tweaking whatsoever (Unity devs used PhysX to create Unity Physics and included it in their project when Building the Engine we use; in exactly the same way that we use unity's API to make a game with which players dont get access to the Unity API). As a result the Physics is not designed to emulate the real world but its good enough for a Game World.
To use it as an Output for visuals would work however. You could, for example, use MatLab to perform calculations and output them to the Engine for visualisation. Of course these visuals are analogous and so may not be totally accurate, requiring Hack or Fix code to get what you want.
Unfortunately this is the nature of a Game Engine.
The things that make a game engine bad for simulation and modelling are some of the same reasons why buying a Geforce TITAN is NOT a good choice for developers.
Hmm i was already afraid of the problem of performance compared to the real world. It was merely the question if and how much I could change the used physx api and how precise it would be. You just pointed out those problems and answered them immediately. Taking this into account i will probably build a shell in unity to have a nice visual touch to the project and then calculate the outcome through a separate program written by myself.
Seeing your comment on the Geforce Titan i assume u mean developing graphically and stuff like rendering, since the development of code and compilation of code is done through the processor, if not can you explain that comment to me?
Yeah the Titan comment comes from its locked Floating point accuracy (which was a feature to allow for faster processing, particularly oriented then for ga$$anonymous$$g). This makes any GPU bound operations inaccurate enough to be considered approximation from a scientific standpoint.
As you know a GPU is capable of processing more than just Graphics code and is beco$$anonymous$$g more and more favoured for many other processing operations given its hardware mathematical capability and its efficiency with certain tasks. Take BitCoin $$anonymous$$ining as an example.
Answer by Naphier · May 13, 2016 at 09:19 AM
It's likely a big "it depends" as most things when considering any engine. Unity will provide you to easy access of C# .NET libraries (up to v2.0 - yeah it's behind). Unity's physics engine won't be of a help (or hinderance) if your simulations already calculate the physics results needed.
This question also depends largely on how many objects you might be moving simultaneously. If it is a large amount (like over 500) then if you know what you're doing writing your own engine may be more efficient. Unity provides things like particle systems and its physics engine to help improve performance for large numbers of moving objects.
However, Unity's already made. You can likely jump in and set up the simulation in a few hours vs the time it might take you to write your own engine. So, it's likely worth a try. I'd at the very least go through and just write the calculations out in some C# classes and do some performance diagnostics to see if the code is capable of running at the speed you need.
Thanks for your answer i will go and try the engine and its advantages. I have not written the code for the calculations yet so i can't try it out immediately, but i will play around a bit in unity to get familiar and get to know it a little. After that i will report back to you what i have done. For now I don't immediately accept the answer since it could come in handy to know someone else's thoughts about this subject.
Yeah, stuff like this really needs trials. Good luck!
Answer by carljoven · Nov 26, 2018 at 06:08 AM
I use unity for some mathematical simulations (related to a game with lots of statistics and random numbers). I can tell you that Unity is great for logging data, creating controls and viewers. Unity is bad when you are running simulations that require millions of formulas and you want your results quickly.
Your answer
Follow this Question
Related Questions
Problem with a ballistic trajectory simulation (rigidbody.velocity) 0 Answers
How to make Rigidbody.AddForce less delayed in Unity3D? 0 Answers
Simulate physics without rendering 2 Answers
Water Toy Ring Toss - How to simulate the rings 1 Answer
How can I slow the velocity of my player without it affecting fall speed? 0 Answers