[quote="alee":1927f3g8]n the subject of object picking, isn't it best if the server dishes out a unique ID to each player that is permanent while they are online, then when you send a movement packet to the server, it affixes your ID to the packet, then sends it to all clients near you (in my game, it would be all clients in your sector). When they recieve the packet, they use events to pick the correct Player instance (Player.Value('ID') = IDinPacket]) or something? (we could pass the contents of the packet to construct using a function with parameters. Or can we do all this in python now without having to pass anything to construct's events?)[/quote:1927f3g8]
On object picking...I've been getting hung up on using Sprite[instance] access which with the new version of Construct perhaps this is not the best way to go. You will notice in the tuts that that method is used ALL over the place to move objects. It is nice because it has good performance.. I'm not sure what the performance would be to pick an object based on ID (of course you could improve it by only picking objects in your sector/screen which should be sufficient).
So you could probably do something like this:
1. New player connects
2. Server issues unique ID to the client with command to spawn a new "myplayer" instance. You are planning to use instances of the same player sprite, correct? When the new sprite is spawned, the 'ID' of the sprite is set in Python using:
objRef=SOL.Sprite #this gets the reference of the new Sprite.
objRef.Value('ID') = uniqueID [/code:1927f3g8]
3. This same info is sent to all other players in the same sector so they too can spawn the new instance.
4. Each tick, player movement, etc is sent to the server along with the uniqueID.
5. The server forwards the movement info to all clients in same sector
6. Each client then picks by value as you mentioned to update the correct myplayer instance. This can all be done in Python now.
So instead of:
[code:1927f3g8]# function to manage player movement
def Network_move(self, data):
You would have:
[code:1927f3g8] def Network_move(self, data):
if myplayer.Value('ID') == data['uniqueID']:
I haven't tested the above out, but believe it will work. You would of course need to limit your search through myplayerto only those objects in sector for performance reasons.
See this thread, which you probably have already read. viewtopic.php?f=2&t=7086&start=10
So with this new approach you lose the coolness of being able to act on your sprite instances directly, you get around all the problems of accessing instances by index when a sprite is destroyed.. which screws up the numbering system.