Hi all
I'm working on a "simple" RTS, using the default multiplayer plugin. Thus far, I have my lobby / room all setup and it works just fine. Furthermore, I'm switching layouts for maps, while the host / peers remain connected. This too works fine. However, I'm having some issues with sync. object.
Setup
In my setup, I'm doing the following:
1. I sync. a Family called Units (position and angle)
Multiplayer -> Sync. Units (Family) with Position and angle, precision Low (int16, 2 bytes) at Normal bandwidth
[/code:6w9f2ae1]
2. When a unit is created, it is associated with [b]Multiplayer.PeerId[/b] for both the Host and the Peer side.
[code:6w9f2ae1]
Units (Family) on created:
Units (Family) -> Set peerId to Multiplayer.PeerID
Multiplayer -> Associate Units (Family) with Multiplayer.PeerID
[/code:6w9f2ae1]
[b]Creating Units[/b]
1. The host is creating a single unit per peer, on layout start
[code:6w9f2ae1]
System for each Player (Sprite that represents peer)
Create object "Worker" (Part of Units Family) on layer "units" at (posX, posY)
"Worker" set peerId to Player.peerId
[/code:6w9f2ae1]
2. The host is responsible for some path finding / moving
[code:6w9f2ae1]
N/A - Not important in this context.
[/code:6w9f2ae1]
This all works well enough - just a very small delay in unit movement, on the peer side.
[b]Problem Creating Multiple Units[/b]
1. The host creates two (or more) units per peer, on layout start
[code:6w9f2ae1]
function createWorker(peerId, posX, posY)
Create object "Worker" (Part of Units Family) on layer "units" at (posX, posY)
"Worker" set peerId to peerId
System for each Player (Sprite that represents peer)
call "createWorker" (Player.peerId, 100, 100)
call "createWorker" (Player.peerId, 150, 100)
...etc
[/code:6w9f2ae1]
While the host appears to have everything in order, all peers mess this completely up. The units are created on the host and the peers. Yet they are not associated with themselves on the peer side. The peers gain control (association) with at most a single unit, which was assigned to them.
Does anyone have an idea why?
Must I really sync. the native object, instead of a family in my setup... Or must I invoke sync. object per created instance (seems unlikely)? Should the host wait some given interval before creating unit number 2, 3.. etc, per peer?