• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Change Camera Height in Region

Status
Not open for further replies.
Level 10
Joined
Sep 25, 2013
Messages
521
I'm making a mult-level city out of walkable doodads and I need a camera system which will change a players camera height depending on which level of the city their camera is centered on. I currently have this, but how do I make it functional for multiple players? I don't know anything about custom scripts, I found this trigger on another post. Is the "set udg_CamX = GetCameraTargetPositionX()" function running for each player or how is it working?

  • Untitled Trigger 001 Copy
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Custom script: set udg_CamX = GetCameraTargetPositionX()
      • Custom script: set udg_CamY = GetCameraTargetPositionY()
      • Set VariableSet TempPoint = (Point(CamX, CamY))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Region 000 <gen> contains TempPoint) Equal to True
              • (Region 002 <gen> contains TempPoint) Equal to True
        • Then - Actions
          • Camera - Set Player 1 (Red)'s camera Distance to target to 2000.00 over 0.50 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Region 001 <gen> contains TempPoint) Equal to True
        • Then - Actions
          • Camera - Set Player 1 (Red)'s camera Distance to target to 3000.00 over 0.50 seconds
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint)
Thank you for your time
 
but how do I make it functional for multiple players?
...
Is the "set udg_CamX = GetCameraTargetPositionX()" function running for each player or how is it working?
Yes, it is running for all players. But each player can have a different CameraX value, so the variable values are not synchronous for players. It's a async function, so brings a different result for each client.

In general, it might be risky to have asynchronous values, because something might run for only some of the players, and a client can get a desync from game.
Though, in your cam case specifically, where only a cam distance is changed, you might be lucky. Because solely changing a player's cam distance locally would have no effect no the gameplay, or on the other players game state, so might not necessarily cause a desync.
But... for example if there exists somewhere, somewhen a trigger which does something like:

If ( Cam Distance To Target > 2000 )
---- Run Trigger A
Else
---- Run Trigger B
End If​

( not a very good example, but at least Cam Distance To Target is again async )

.. then there will be a problem, because the value of a player's Cam Distance is async, and so for some players Trigger A will run, and for some others Trigger B, which then definitely would couse a desync.

Sometimes it might be not too easy to decide, but from here there are two approaches:
  1. You want to have synchronous values, so you can safely use a player's cam values for code which might have effect on all players' game session.

  2. A player's cam value can never have effect on the gameplay, and is only used like in your first post, to affect a player's unrisky local cam value.

1 =>
There are ways, like Pyrogasm's linked library, to sync local values for all players, so it's safe again to work with them globally. With newer patches there are now also cool natives to sync data and there's an example which exactly covery what you need with CameraTargetPositionX/Y: [Solved] - Target of (Current Camera) desync. But JASS is always needed.

2 =>
You need to work with a player's cam locally from here on, and be aware that values are out of sync. GetLocalPlayer
The trigger would need to include a loop through all players, and use the GetLocalPlayer() If-statement for each of them, to change cam locally for everyone.
 
Last edited:
Status
Not open for further replies.
Top