I did something similar to what you describe by writing a custom Python server to communicate with a Unity client.
Most highly interactive games can't just use TCP, because it has too much overhead and you want different reliability for different kinds of game-data. For instance, if you're sending a constant stream of position updates, you don't need them all to be reliable. E.g. just send the last N frames of updates in each unreliable datagram. That way if one is missed, you can just interpolate / extrapolate. Triggering particle effects or other non-critical eye-candy can also be unreliable.
Check out RakNet. It's a really solid C++ networking library optimized for games and similar soft-realtime use cases. Internally, this is what Unity's built-in networking is implemented with. Since I couldn't access Unity's RakNet directly, I wrapped the DLL for access from my own client-side
Unity code. I used custom Python on the back-end.
Another option to consider is SmartFox Server. It does things like lobbies, IP block ranges, and sessions management.
Chances are you'll end up re-implementing a lot of functionality that they've written already. I was okay with that, because I wanted to learn how.
Hope this helps.
You should decouple your network polling from the game update loop to avoid headaches later. I.e. don't do it in Update. Also, Update is frame-rate / display-dependent, whereas FixedUpdate is not.
The title sounded very interesting, I'm highly interested in Unity and Indoor positioning. But .. that's not part of that article. This is just a tiny C# class for network operations in Unity, it seems?
Disclaimer: C#'s what I earn my money with. That article confuses the hell out of me.
Why would you ever yield return a single value?
Why is the class name in lowercase/camelCase for 'networkSocket'?
Why are the method names following the (.Net standard) PascalCase convention in 'networkSocket', but using the (Java et al) camelCase in the samples below?
In my opinion this doesn't show a thing about the stack from the title and the C# is (arguably of course) a little messy. Even ignoring the inconsistent style (catching "Exception" comes to mind, public fields instead of properties, etc).
Thats a special case in the Unity game engine as the Update() functions of each script are called in the Game loop once per frame. Now if you do a WWW Request without yielding out of the game loop, the game will hang in that frame until the WWW Request is finished. By yielding it does the WWW Request asynchronous outside of the game loop and comes back to the Debug statement when the WWW Request is done.
I share your view on the incosistent Code Style though, it should be PascalCase all the way and i have always done it like that in Unity projects.
Public fields are another thing special to Unity, as you are able to modify public fields directly within the IDEs Object Inspector, which allows you to modify values while testing the game for example. You can also use Properties but those wont allow you said Inspector modifications (at least in Version 3.x that was the case).
The article is the first part of a series that will highlight our technology stack as we are developing it. The HW for indoor positioning, the algorithm, the twisted server and the chef recipes will all be highlighted in the incoming posts.
For what concerns the rest, you are totally right. I have been googling around to see how to hack a tcp channel to connect our Unity client to the twisted tcp server and I could not find anything. The documentation is kinda lacking, so I put together a naive prototype with the intention of sharing it for whom might have similar needs.
I will polish the code and post the highlights of the rest of the stack soon enough
Awesome, i have quite a bit of unity3d experience for game development and now as a freelancer would love to work on some non-gaming related Unity3d Applications.
We currently are in discussions for a project that will visualize a sailing race in 3D with live GPS locations of the actual boats. Viewers could actually see the visualized race in the browser (flash) or on their mobile device of choice!
As a performance hint: I dont think you need to read the Socket every frame (so 60 times per second at 60fps), doing it 5-10 times per second should be more than enough as there will be some latency involved anyway.
You're right, for simple indoor positioning, reading the socket 5 times per second is a good enough rate. For sport applications we'll probably have to increase it a bit.
Your 3D application sounds awesome, d'you have any link?
Could you expand upon the reason why you chose to use 3D over 2D floor plans? From a technological standpoint it's very cool, but I was wondering what value it adds for the business and customer satisfaction?
If I understand your product correctly, 3D may bog down your customer service channels because people will pay more attention to the accuracy of your model (when it may not matter) instead of the metrics you are trying to convey.
There are also some logistic issues that I'm wondering how you will overcome:
-If I'm a local technician, this will be a great tool to spot check the receiver locations. But I have no way to (accurately and easily) measure if it's 4 feet or 6 feet off the ground.
-If I'm a school admin, I need a quick graphic where the only change is the metrics I'm trying to analyze. Making me zoom/move around to see different classrooms / buildings on campus is time I probably don't have. Even pre-made locked 3D views distract me with extra information about the building when I'm really trying assess classroom attendance. And while showing the flow of students from classroom to classroom in 3D would be cool, it would again be much more useful as an analytical tool in 2D where the information being displayed is limited and focused on the task at hand.
3D is typically used to engage someone emotionally or show a highly detailed item. Emotionally, it allows us to connect to an event (such as the SailBoat Race) by filling our eyes with information that can only be gleaned at that time/space in reality. Analytically, it is a great tool to convey and compare important minute details, such as light coming into a room or organs wrapping around each other.
It's a great tool when used appropriately and I do see some value added by making an admin see/feel the cramped musky hallways of a building to explain emotionally why students go to class less often in certain buildings. But I equally wonder if you won't find yourself in uphill battle as people focus more on the problems with your model instead of the problems with their attendance?
On top of all that, what happens if:
-I have a Netbook/Chromebook with too little horsepower for 3D?
-I have to install flash just to use your product and can't (Mac)?
-My internet connection is slow, intermittent or a combo?
You have a point about using 3D in the attendance monitoring for universities. In facts this is why the viewer employed there is gonna be 2D and used only in case of emergencies ( privacy is a big concerns for education institutions and we do not want to show where people are exactly, but monitor their attendance and gather anonymous stats).
What we are trying to accomplish with the stack we are currently using is a generic multipurpose demo IP platform that anybody can extend with their own applications. In this case the 3rd dimension is something that might be very useful to show case.
For what concerns the rest of your (very valid) comments, Unity3D can export to WEBGL and other engines, not only flash. We will consider our options but right now for this initial beta release, flash sounds good enough.
I am looking forward to reading the next few articles in the series. Mapping applications are awfully hard to get right [1]. There is just so much to do and do correctly that it is quite the technical achievement to create a functional mapping application. Doing it in 3d seems more difficult.
But, I have a huge philosophical disagreement with the (education) product that beestar offer. I am a university student, and the freedom and independence that comes with being a student is invaluable. I transitioned from the narrowly rule-bound high school to the liberated, independent university life. I feel it is my responsibility and mine alone for my attendance. I would feel like I was back at school if my attendance was monitored. So many universities are places that engender freedom of thought, movement and expression. It seems as if this "were you there?" Big Brother system stands in opposition to the liberty offered by universities. The system that can offer you freedom unlike in any other institution instead clamps down on you, Theory X style [2]. If I were to attend a university using this system, I would feel less free than I do now. I don't think that removing someone's freedom to guarantee attendance is a worthwhile payoff for the education they'd be receiving
I understand your concerns and in facts the system has been designed for 1) UK universities and it generates statistics based on 2) anonymous positioning traces.
Point 1) is important because due to the legislation in UK, students are obliged to scan their ID card at the barcode scanner in class to certify their presence at lesson. Just like employees at the supermarket. I feel that our system frees them to have to do that. The student positions are not visible unless there is an emergency and even in that case realtime viewer does not show any data on whom the student (or lecturer) is. It just shows to the firefighter that there is someone at the second floor in room 3A.
For what concerns point 2) you can think that we used anonymized positions as GPS navigators backend use the device traces to generate data about traffic jams, map corrections and so on. This data is used to improve campus life as it gives an idea how to distribute resources optimally. I remember that I was very frustrated as a student when I never seemed to find room in a computer lab while the classes adjacent where always very busy.
'This data is used to improve campus life as it gives an idea how to distribute resources optimally'. My university really needs this; just today I wasn't able to get a seat in the lab for an originally 2-hour session. We were split in two groups and each group got 1 hour in the lab instead of 2. This is a real problem and I would agree to carry a beacon-card if you could guarantee that my data sent is anonymous. And given the fact that attendance certification is law in the UK, I think that the safety and security use cases for this technology are completely invaluable. The firefighter example shows that you could actually end up saving lives.
As CEO, you should note that your comment completely repositioned my attitude towards your product. This is because your website is clearly aimed at decision makers at universities, whereas all I (a student) saw was a system conducive to draconian monitoring system. You should probably make your site more clearly demarcated. At http://beestar.eu/insight/learning-analytics it seems as if about half the points are targeted at students while the other half at educators. It seems slightly mismatched. And you also don't mention how this system could improve safety (I see the benefits of the firefighter case now that it's been explained)
I have to thank you a lot for your feedback, I really appreciate it. I will modify the website so that it will be clearer where we stand with our product
so using 3d/scenegraph/scripting engine for 3d and twisted (python networking engine) for networking. What's so special about that? Unity doesn't work on linux btw.
For example the fact that the HW as well as the SW has been entirely developed from scratch by the same startup which is competing in a market where usually the software is deployed on a workstation as a custom windows executable connected to SQLServer backend and clumsy communicating with the HW through USB or, worse COMM ports.
RTLS companies are very conservative with technology. We are trying to modify the trend and use something a little cooler
I'm not totally sure if this is relevant to the original post, but I think Unity also offer a browser plugin which, I assume, can be used interchangeably with the Flash export.
Most highly interactive games can't just use TCP, because it has too much overhead and you want different reliability for different kinds of game-data. For instance, if you're sending a constant stream of position updates, you don't need them all to be reliable. E.g. just send the last N frames of updates in each unreliable datagram. That way if one is missed, you can just interpolate / extrapolate. Triggering particle effects or other non-critical eye-candy can also be unreliable.
Check out RakNet. It's a really solid C++ networking library optimized for games and similar soft-realtime use cases. Internally, this is what Unity's built-in networking is implemented with. Since I couldn't access Unity's RakNet directly, I wrapped the DLL for access from my own client-side Unity code. I used custom Python on the back-end.
Another option to consider is SmartFox Server. It does things like lobbies, IP block ranges, and sessions management.
Chances are you'll end up re-implementing a lot of functionality that they've written already. I was okay with that, because I wanted to learn how.
Hope this helps.
You should decouple your network polling from the game update loop to avoid headaches later. I.e. don't do it in Update. Also, Update is frame-rate / display-dependent, whereas FixedUpdate is not.