[Q] Pathfinding/collision on Server

I couldnt find much about that, but how do you run pathfinding and collision on the server (like photon, smartfox ect.)?

I could run it on one client yes, but thats not good for net perfomance and its a weak place for exploits.
Dedicated unity server, it performs not very well as far as I heard, especially when you need a lot of instances for different games.

I actually see only one possibilities, license the sourcecode to get meshdata and pathing information from a Level for my server application that runs that tasks.

In general, they can’t. As far as I know neither Photon or SmartFox has the required math libraries or collision libraries built in, and even if they had there is no communication back to unity for that type of data.

As you say neither of these approaches are a good solution (I’ve tried both of them and even more weird schemes like clustering calculations on all clients, etc, it just doesn’t work)

This is probably overkill, and not how I solved it. I’ll list my solution to the problem.

Basically I built my own server (using Lidgren for networking and SlimMath for the core math operations), it runs as a stand-alone executable (built using .NET, runs on Windows and Linux/Mono). I built my own pathfinding implementation (I only needed path finding on one plane (XZ), so I used a grid-based A* implementation that can handle really big worlds - talking up to 26 million nodes and more) that can run both on the unity clients for local stuff and on the server for AI, authoritative movement, etc.

I also utilize the SlimMath library for doing translation and rotation calculations on the server for the parts that need that. I then implemented my own scene graph on the server, it’s pretty simple as the server does no real rendering and you really only need very simple relations between objects. On top of this I implemented simple collision detection on the server, it supports bounding boxes, bounding spheres and bounding planes. That’s it. You do not want to end up doing mesh based calculations on the server, it will cost you to much.

After I had my server running smoothly (somewhat, at least ;p) I implemented an exporter from unity to a custom .xml format that the server understands. I use this to export the parts of a scene that I need to the server so it has a simple understanding of the game world (where objects are, what type an object is (what prefab a object is an instance of), etc.), bounding volumes and some housekeeping data.

All this is hooked up with a couple of unity extensions, so that you can handle everything through the unity editor and the export is automatically done when you build or play (by hitting the play button) the game through the editor.

Footnote: If you’re interested in my solution it will be in closed beta in 2-3 weeks, and then in public beta on the asset store for 100€ during November some time.

Thanks for your fast reply,
I’m looking forward to your solution, seems to cover what I need and may give me a kick start for my own game server. :smile:
I dont plan big worlds ( it will be more the size of an warcraft3 rts map and smaller) but its good to know that it would scale up well if I ever need it.

Building a MOBA-style game? :slight_smile:

Gotcha :wink: yes exaclty something in that direction.

Same here, the game type has very special requirements. (which is why I ended up building my own server).

A very good initiative in general!
I would also be interested in a similar plugin for Photon (instead of lidgren) in the asset store :).

This isn’t really a plugin, Lidgren is just an UDP library in the same way that Unity uses RakNet for it’s own networking. Everything is handcrafted from scratch except the lowest UDP layer.

Sorry, no interest in building anything for Photon, as they’re going to end up being my competition :slight_smile:

Your competition?

I am currently making a load-balanced game with Photon and I would be interested in another solution.
Could you tell me more about what you want to offer? (PM me if you want to).

My server (and unity integration) targets room-based games where you have 2-64 players in each room, and 2-1024 networked game objects (actors) in each room. I’m creating a server and unity-client plugin that has support for a bunch of things I couldn’t find for Photon (collision detection, authoritative movement, etc.).

Maybe this thread gives further info…
http://forum.unity3d.com/threads/104770-Generic-multiplayer-server-what-s-needed-in-terms-of-features

It does, especially the big post towards the end, after the video.

It shouldn’t be much work to plug the features you’re going to implement - to Photon (and that’s what I’ll happily do myself).
So you just restrict the amount of customers for your solution.

What’s your plan to handle a high amount of ccus?
What would be the max numbers of ccus that one physical machine will be able to handle?

As in every project - it would be better to have several features nailed correctly, instead of spreading the effort over a ton of roughly implemeted things! (personal opinion)

It would be interesting to see ‘one man few months’ vs. ‘exitgames team’ competition ;).

I don’t want to be rude, but all the stuff that is developed is under a commercial license and no source code is available and reverse engineering it is strictly forbidden in the license.

This server is just a bi-product of the game I’m building so I’m not worried about restricting my consumer base.

By far the best way is to use a hardware load balancer, but this is so dependent on the type of game you build that it’s hard to give a clear cut answer.

In thoery 65k on a windows box, but this is of course not reality. One physical machine is anything from a x486 from -94 to a 2xOcta Core 64gb SSD-RAID monster. Very hard to answer.

Which is exactly what I’m going for!

Ha, well… i can only answer for myself and I know how to build rock solid software :slight_smile:

Oh, I had the impression the ‘interesting part’ with path finding and math is supplied with sources - sorry!
Btw, thanks for showing us SlimMath - this is a good place to start for people wanting the same functionality with Photon.

Please share the ccu numbers if you do any tests that are close to reality :).

Is there any place where one can get to know your previous experience in building software?

The pathfinding is proprietary and sources are not supplied. SlimMath is open source (MIT license) and is of course available, it is however a very small part.

Everything for exporting scenes from unity and importing them on the server is 100% proprietary also, etc.

I will, the highest number I’ve tested with atm is 100 CCU, the server didn’t break a sweat, hovering between 1-3% CPU on my laptop.

My last major project is an opensource JIT compiler for javascript, which can be found here: GitHub - fholm/IronJS: IronJS - A JavaScript implementation for .NET

I spend most of my work time building high performance network/web backends on various platforms, and occasionally dabble in android development.

Would the server solution you are building be a good choice for a game that allows player movement on all 3 axes, say a flight or space sim? 64 players in a room is my target, and I have serious doubts about being able to get there with the solutions currently out there. Unless of course I don’t handle player position in an authoritative manner.

You quoted the part about pathfinding, so I assume you ment if the pathfinding would work for a true 3-axis game. No it would not, the path finding is built specifically for one plane games. Besides, doing path finding in true 3d space with pretty much no obstacles like space or the air, I would just basically use LookAt and then if I bump into anything solve it on the spot.

Other then that I think it should be no problem what so ever to use the server.

Ah, no, I misread it, sorry. No need for 3d pathfinding, just 3d movement/collision detection.

Anyway, in that case, very interesting, just wish I had the time to help you test, but I don’t yet. :confused:

Good luck, sounds like what you’re building could be very beneficial to a lot of people!