• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Camera System

Status
Not open for further replies.
Level 37
Joined
Jul 22, 2015
Messages
3,485
Looking to get some constructive criticism on my camera system for my project map. The way it works is if either of the two players type "-cam" followed by a number, it sets the camera height to that number. Typing "-cam default" will set it back to... well default height! I have it in a loop so that using the scroll wheel doesn't reset the camera height.


  • Camera Init
    • Events
      • Player - Player 2 (Blue) types a chat message containing -cam as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -cam as A substring
    • Conditions
      • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Not equal to <Empty String>
    • Actions
      • Set CameraSystem_Group = (Player group((Triggering player)))
      • Set CameraSystem_Height = (Real((Substring((Entered chat string), 6, 9))))
      • Trigger - Turn on Camera Loop <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 6, 12)) Equal to default
        • Then - Actions
          • Camera - Set (Triggering player)'s camera Distance to target to 1650.00 over 1.00 seconds
          • Custom script: call DestroyForce (udg_CameraSystem_Group)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in CameraSystem_Group) Equal to 0
            • Then - Actions
              • Trigger - Turn off Camera Loop <gen>
            • Else - Actions
        • Else - Actions
  • Camera Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in CameraSystem_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CameraSystem_Height Less than or equal to 3000.00
              • CameraSystem_Height Greater than or equal to 500.00
            • Then - Actions
              • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height over 1.00 seconds
            • Else - Actions
              • Game - Display to CameraSystem_Group for 5.00 seconds the text: |cffff0000Camera Er...
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CameraSystem_Height Greater than or equal to 3001.00
                • Then - Actions
                  • Set CameraSystem_Height = 3000.00
                  • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height over 1.00 seconds
                  • Game - Display to CameraSystem_Group for 5.00 seconds the text: Camera height has b...
                • Else - Actions
                  • Set CameraSystem_Height = 500.00
                  • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height over 1.00 seconds
                  • Game - Display to CameraSystem_Group for 5.00 seconds the text: Camera has been set...





EDIT: This is for the updated trigger.


  • Camera Init
    • Events
      • Player - Player 2 (Blue) types a chat message containing -cam as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -cam as A substring
    • Conditions
      • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Not equal to <Empty String>
    • Actions
      • Set CameraSystem_Group = (Player group((Triggering player)))
      • Set CameraSystem_Player = (Player number of (Triggering player))
      • Set CameraSystem_EnteredString = (Substring((Entered chat string), 6, 9))
      • Set CameraSystem_MinHeight = 500.00
      • Set CameraSystem_MaxHeight = 3000.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 6, 12)) Equal to default
        • Then - Actions
          • Camera - Reset camera for (Triggering player) to standard game-view over 1.00 seconds
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Real(CameraSystem_EnteredString)) Less than CameraSystem_MinHeight
                  • (Real(CameraSystem_EnteredString)) Greater than CameraSystem_MaxHeight
            • Then - Actions
              • Game - Display to CameraSystem_Group for 2.00 seconds the text: |cffff0000Camera Er...
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Real(CameraSystem_EnteredString)) Greater than CameraSystem_MaxHeight
                • Then - Actions
                  • Game - Display to CameraSystem_Group for 2.00 seconds the text: Setting camera heig...
                  • Set CameraSystem_Height[CameraSystem_Player] = CameraSystem_MaxHeight
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Real(CameraSystem_EnteredString)) Less than CameraSystem_MinHeight
                • Then - Actions
                  • Game - Display to CameraSystem_Group for 2.00 seconds the text: Setting camera heig...
                  • Set CameraSystem_Height[CameraSystem_Player] = CameraSystem_MinHeight
                • Else - Actions
            • Else - Actions
          • Set CameraSystem_Height[CameraSystem_Player] = (Real(CameraSystem_EnteredString))
          • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height[CameraSystem_Player] over 1.00 seconds
  • Camera Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in CameraSystem_Group and do (Actions)
        • Loop - Actions
          • Set CameraSystem_Player = (Player number of (Triggering player))
          • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height[CameraSystem_Player] over 1.00 seconds
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
So, what's your question?

I was asking for constructive criticism on the camera system I made. I'm trying to get better at GUI, so I want to find out if there is a better approach on what I want the system to do versus what I executed.

Apply the min/max height within the first trigger. Second trigger should just be setting the values, no need for if/then/else just set the cameras.

Also do the other camera values: pitch, height, field of view, etc

Is this better? I just need height for my project :p I don't think there is no need to add other camera values.
  • Camera Init
    • Events
      • Player - Player 2 (Blue) types a chat message containing -cam as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -cam as A substring
    • Conditions
      • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Not equal to <Empty String>
    • Actions
      • Set CameraSystem_Group = (Player group((Triggering player)))
      • Set CameraSystem_Height = (Real((Substring((Entered chat string), 6, 9))))
      • Set CameraSystem_MinHeight = 500.00
      • Set CameraSystem_MaxHeight = 3000.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CameraSystem_Height Greater than or equal to CameraSystem_MinHeight
          • CameraSystem_Height Less than or equal to CameraSystem_MaxHeight
        • Then - Actions
          • Trigger - Turn on Camera Loop <gen>
        • Else - Actions
          • Game - Display to CameraSystem_Group for 2.00 seconds the text: |cffff0000Camera Er...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CameraSystem_Height Greater than CameraSystem_MaxHeight
            • Then - Actions
              • Game - Display to CameraSystem_Group for 2.00 seconds the text: Setting camera heig...
              • Set CameraSystem_Height = CameraSystem_MaxHeight
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CameraSystem_Height Less than CameraSystem_MinHeight
            • Then - Actions
              • Game - Display to CameraSystem_Group for 2.00 seconds the text: Setting camera heig...
              • Set CameraSystem_Height = CameraSystem_MinHeight
            • Else - Actions
          • Trigger - Turn on Camera Loop <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 6, 12)) Equal to default
        • Then - Actions
          • Camera - Set (Triggering player)'s camera Distance to target to 1650.00 over 1.00 seconds
          • Custom script: call DestroyForce (udg_CameraSystem_Group)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in CameraSystem_Group) Equal to 0
            • Then - Actions
              • Trigger - Turn off Camera Loop <gen>
            • Else - Actions
        • Else - Actions
  • Camera Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in CameraSystem_Group and do (Actions)
        • Loop - Actions
          • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height over 1.00 seconds
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
You're using the same camera height variable for all players, so if any player sets the height everyone will get that same height.

You need to change CameraSystem_Height to an array variable, and for array index use player number of picked player (triggering player in the first trigger)

I actually never encountered that problem when I tested with a friend of mine. However, it does make sense that if another player were to type a different value, it would apply to both of them. Regardless, I now made CameraSystem_Height an array! I updated the original post to include the new triggers.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
In the loop trigger, you need to set CameraSystem_Player to the player number of picked player.

In the first trigger, move this line:
  • Custom script: call DestroyForce (udg_CameraSystem_Group)
to the very end of the trigger.

You can remove the trigger turn off/turn on stuff and just leave it permanently looping. It will have no impact on performance (you'd need a few thousand of these going to get noticeable lag)
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
In the loop trigger, you need to set CameraSystem_Player to the player number of picked player.

I need to have two variables declaring the player number? One in init and another loop?

In the first trigger, move this line:
  • Custom script: call DestroyForce (udg_CameraSystem_Group)
to the very end of the trigger.

Putting this at the very end of the trigger will destroy the feature of "not losing camera height by scrolling." The reason I have it in the default if nest is because the only reason a player would be leaving the group is if they want to go back to normal camera height.

You can remove the trigger turn off/turn on stuff and just leave it permanently looping. It will have no impact on performance (you'd need a few thousand of these going to get noticeable lag)

Done :)
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I need to have two variables declaring the player number? One in init and another loop?

Do this in the loop:
  • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height[(Player number of (Picked player))] over 1.00 seconds
My previous message was a little unclear.

Putting this at the very end of the trigger will destroy the feature of "not losing camera height by scrolling." The reason I have it in the default if nest is because the only reason a player would be leaving the group is if they want to go back to normal camera height.

Your loop is always on for all players anyway, all you're doing is setting the height for that player. There should be no removing from groups.

Here's what mine in one of my maps looks like:
  • Auto Camera
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set pid = (Player number of (Picked player))
          • Camera - Set (Picked player)'s camera Distance to target to PlayerZoom[pid] over 0.20 seconds
  • Player Commands
    • Events
      • Player - Player 1 (Red) types a chat message containing - as A substring
    • Conditions
    • Actions
      • Set pid = (Player number of (Triggering player))
      • Set InputString = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(InputString, 1, 5)) Equal to -zoom
        • Then - Actions
          • Set PlayerZoom[pid] = (Real((Substring(InputString, 7, (Length of InputString)))))
          • Camera - Set (Triggering player)'s camera Distance to target to PlayerZoom[pid] over 1.00 seconds
        • Else - Actions
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Do this in the loop:
  • Camera - Set (Picked player)'s camera Distance to target to CameraSystem_Height[(Player number of (Picked player))] over 1.00 seconds
My previous message was a little unclear.

Done! :) If I may ask, what is the reason we have to set the player number in the loop as well?


Your loop is always on for all players anyway, all you're doing is setting the height for that player. There should be no removing from groups.

Here's what mine in one of my maps looks like:
  • Auto Camera
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set pid = (Player number of (Picked player))
          • Camera - Set (Picked player)'s camera Distance to target to PlayerZoom[pid] over 0.20 seconds
  • Player Commands
    • Events
      • Player - Player 1 (Red) types a chat message containing - as A substring
    • Conditions
    • Actions
      • Set pid = (Player number of (Triggering player))
      • Set InputString = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(InputString, 1, 5)) Equal to -zoom
        • Then - Actions
          • Set PlayerZoom[pid] = (Real((Substring(InputString, 7, (Length of InputString)))))
          • Camera - Set (Triggering player)'s camera Distance to target to PlayerZoom[pid] over 1.00 seconds
        • Else - Actions

Ahh I get you :) unfortunately, I can't take that approach since I have 3 conditions that check the entered chat string before setting the camera height.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Done! :) If I may ask, what is the reason we have to set the player number in the loop as well?

Not sure if I understand you correctly or if you don't understand arrays fully; you need to use the correct array index to fetch that specific player's value.

Ahh I get you :) unfortunately, I can't take that approach since I have 3 conditions that check the entered chat string before setting the camera height.

No reason why you can't fit your conditions in there.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Not sure if I understand you correctly or if you don't understand arrays fully; you need to use the correct array index to fetch that specific player's value.

I ask because I already have this in the init trigger.
  • Set CameraSystem_Player = (Player number of (Triggering player))
What's the reasoning behind doing that again in the loop?

No reason why you can't fit your conditions in there.

Ahh got it! Updated trigger. Sorry I had to really think about it :p so there shouldn't be a need to destroy the group then since the loop is always on, right?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
To find the player number of the player you're picking.

Example:

Player 1 sets the camera height, so you set CameraSystem_Player to 1.
The loop runs, and CameraSystem_Player is still equal to 1 so when the players are picked, both of their cameras are set to player 1's height value, since it's setting it to CameraSystem_Height[1]
Do you see the problem there?

It becomes a problem further when player 2 now sets his camera height, now both player 1 and 2 will have their heights set to the new value.

But remember you don't need to use a variable, simply using (Player number of (Picked player)) is completely fine.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
To find the player number of the player you're picking.

Example:

Player 1 sets the camera height, so you set CameraSystem_Player to 1.
The loop runs, and CameraSystem_Player is still equal to 1 so when the players are picked, both of their cameras are set to player 1's height value, since it's setting it to CameraSystem_Height[1]
Do you see the problem there?

It becomes a problem further when player 2 now sets his camera height, now both player 1 and 2 will have their heights set to the new value

Ahh okay! That makes a lot more sense :p

But remember you don't need to use a variable, simply using (Player number of (Picked player)) is completely fine.

I know :p I just didn't feel like always trying to look for (Player number of (Picked player)) everytime I changed it.
 
Status
Not open for further replies.
Top