Evening,
I'm making a Camera Zoom system but am experiencing desycns between players. The below code works fine:
Now I want to ensure the Camera's distance to target does not change (unless that player enters a new zoom command of course). Unintentional zoom changes often occur when a player uses their mouse scroll wheel which resets it to Warcraft 3 default camera distance (1650). I thought I could periodically check if the camera is not at the desired zoom and correct it. I've tried various approaches but they all desync unfortunately.
Tested using two Warcraft 3 clients on the same computer. See attached screenshot for in-game desync symptoms Failed coded approaches below:
As I've researched, camera data is not synced between players though I didn't think my triggers were causing local clients to access desynced network data (as I understand desyncs to happen when a client tries to access networked data when it is not synchronized between clients). Each client is simply comparing it's own local variable (Player_LocalCamZooom to a synced integer (Player_CameraZoom[*array*]) then setting it's own local camera but not touching the local camera data of another client or it's local Variable.
1. Why and where is the desync occuring?
2. How can I fix this?
3. If this approach can't work, are there any other methods I could take to "lock" player's distance to target?
I'm making a Camera Zoom system but am experiencing desycns between players. The below code works fine:
-
Map Init
-
Events
- Map Initialization
- Conditions
-
Actions
- Custom script: set udg_LocalPlayer = GetLocalPlayer()
-
Events
-
Camera Zoom
-
Events
- Player - Player 1 (Red) types a chat message containing -zoom as A substring
- Player - Player 2 (Blue) types a chat message containing -zoom as A substring
- Conditions
-
Actions
- Set VariableSet TempInteger1 = (Integer((Substring((Entered chat string), 6, 10))))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempInteger1 Greater than or equal to 1200
- TempInteger1 Less than or equal to 2200
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempInteger1 Not equal to Player_CameraZoom[(Player number of (Triggering player))]
-
Then - Actions
- Game - Display to (Player group((Triggering player))) for 8.00 seconds the text: (Setting camera to + ((String(TempInteger1)) + distance.))
- Camera - Set (Triggering player)'s camera Distance to target to (Real(TempInteger1)) over 1.00 seconds
- Set VariableSet Player_CameraZoom[(Player number of (Triggering player))] = TempInteger1
-
Else - Actions
- Game - Display to (Player group((Triggering player))) for 8.00 seconds the text: (You are already Zoomed at a Distance of + ((String(TempInteger1)) + .))
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Else - Actions
- Game - Display to (Player group((Triggering player))) for 8.00 seconds the text: You can only Zoom t...
-
If - Conditions
-
Events
Now I want to ensure the Camera's distance to target does not change (unless that player enters a new zoom command of course). Unintentional zoom changes often occur when a player uses their mouse scroll wheel which resets it to Warcraft 3 default camera distance (1650). I thought I could periodically check if the camera is not at the desired zoom and correct it. I've tried various approaches but they all desync unfortunately.
Tested using two Warcraft 3 clients on the same computer. See attached screenshot for in-game desync symptoms Failed coded approaches below:
-
Camera Correct
-
Events
- Time - Every 0.30 seconds of game time
-
Conditions
- CinematicRunning Equal to False
-
Actions
-
Player Group - Pick every player in PlayerGroupAllies and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LocalPlayer Equal to (Picked player)
-
Then - Actions
- Set VariableSet Player_LocalCamZoom = (Integer((Distance to target of (Current camera))))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- Player_LocalCamZoom Less than or equal to (Player_CameraZoom[(Player number of (Picked player))] - 10)
- Player_LocalCamZoom Greater than or equal to (Player_CameraZoom[(Player number of (Picked player))] + 10)
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- Game - Display to (Player group((Picked player))) for 2.00 seconds the text: (String(TempInteger1))
- Camera - Set (Picked player)'s camera Distance to target to (Real(Player_CameraZoom[(Player number of (Picked player))])) over 1.00 seconds
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Player Group - Pick every player in PlayerGroupAllies and do (Actions)
-
Events
-
Camera Correct Copy
-
Events
- Time - Every 0.30 seconds of game time
-
Conditions
- CinematicRunning Equal to False
-
Actions
- Set VariableSet Player_LocalCamZoom = (Integer((Distance to target of (Current camera))))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- Player_LocalCamZoom Less than or equal to (Player_CameraZoom[(Player number of (Picked player))] - 10)
- Player_LocalCamZoom Greater than or equal to (Player_CameraZoom[(Player number of (Picked player))] + 10)
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- Game - Display to (Player group(LocalPlayer)) for 2.00 seconds the text: (String(Player_LocalCamZoom))
- Camera - Set LocalPlayer's camera Distance to target to (Real(Player_CameraZoom[(Player number of (Picked player))])) over 1.00 seconds
- Else - Actions
-
If - Conditions
-
Events
As I've researched, camera data is not synced between players though I didn't think my triggers were causing local clients to access desynced network data (as I understand desyncs to happen when a client tries to access networked data when it is not synchronized between clients). Each client is simply comparing it's own local variable (Player_LocalCamZooom to a synced integer (Player_CameraZoom[*array*]) then setting it's own local camera but not touching the local camera data of another client or it's local Variable.
1. Why and where is the desync occuring?
2. How can I fix this?
3. If this approach can't work, are there any other methods I could take to "lock" player's distance to target?
Attachments
Last edited: