Hi there,
My Question Short Version:
What's the efficiency of using "Pick instance with UID"? Does "Pick instance with UID" simply access in to an array with an index of UID, or does it do some kind of searching?
Long Version:
I'm trying to make a simple mmorpg with Construct 2. The problem I am facing is that when the server (written in construct 2) broadcasts a position of a monster, the client has to find the same monster on the client side and update the client monster's position.
Now I first tried doing this simply by assigning an instance variable called "UniqueMonsterId" that is the same in all clients (but of course UID may not be, depending on the order that monsters are created in), but the problem with this was that I had to look through all the monsters on each update to check if the monster's UniqueMonsterId was the same as the one broadcast by the server, and if it was update it. This gives me an O(n^2) complexity.
I tried to improve it by creating a relational array which linked the UniqueMonsterId to a particular UID, so now I can use a "Pick instance with UID" to find my monster (instead of searching through all the monsters). However the efficiency doesn't appear to have improved.
My question is, does "Pick instance with UID" simply access in to an array with an index of UID, or does it do some kind of searching? Because if it just accesses an array this would reduce the complexity down to O(1) which would be a great improvement!
Please let me know if anyone can shed some light on to this. Without being able to figure this out, my game won't be able to have more than 10 monsters at a time without maxing out one of my CPUs!
Thanks for your help! Cheers!
Dengke / ValkyrieGames