• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Zooming

Status
Not open for further replies.
Level 12
Joined
Jun 1, 2010
Messages
748
How to make a map instead of -zoom 3000 entering text, I want to know how do I zoom by scrolling. In my map I do not need to scroll down, straight view. Because it is a strategy map and the whole map encompasses Europe, Middle East and North Africa, I need it to be seen like from a satelite (aerial view)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
It's impossible to detect the mousewheel in GUI or in Jass.
There are alternatives you might want to choose from instead, such as arrow keys, escape key, a unit with zoom abilities etc...
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Also impossible, you could however use any alphabetical character instead by creating abilities with hotkeys.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I would like to zoom by arrow keys, up and down.

Then take a look at these GUI events:

  • Player - Player 1 (Red) Presses the Up Arrow key
  • Player - Player 1 (Red) Releases the Up Arrow key
  • Player - Player 1 (Red) Presses the Down Arrow key
  • Player - Player 1 (Red) Releases the Down Arrow key
Here is a small tutorial on arrow key movement with a camera system:
http://www.hiveworkshop.com/forums/...s-279/arrow-key-movement-camera-system-43201/

I'm sure once you've read it you'll be abled to apply this method to your zoom problem ;)

It should be quite simple:
While the Up Arrow key is pressed -> zoom in
When the Up Arrow key is released -> stop zooming
While the Down Arrow key is pressed -> zoom out
when the Down Arrow key is released -> stop zooming
While both Down and Up Arrow key are being pressed -> stop zooming
While Up Arrow key is pressed and Down arrow key is released -> zoom in
While Down Arrow key is pressed and Up arrow key is released -> zoom out
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Something like this should work:

  • Press Up
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
      • Player - Player 2 (Blue) Presses the Up Arrow key
      • Player - Player 3 (Teal) Presses the Up Arrow key
      • Player - Player 4 (Purple) Presses the Up Arrow key
      • Player - Player 5 (Yellow) Presses the Up Arrow key
      • Player - Player 6 (Orange) Presses the Up Arrow key
      • Player - Player 7 (Green) Presses the Up Arrow key
      • Player - Player 8 (Pink) Presses the Up Arrow key
      • Player - Player 9 (Gray) Presses the Up Arrow key
      • Player - Player 10 (Light Blue) Presses the Up Arrow key
    • Conditions
    • Actions
      • Set Up_Pressed_Player[(Player number of (Triggering player))] = True
  • Release Up
    • Events
      • Player - Player 1 (Red) Releases the Up Arrow key
      • Player - Player 2 (Blue) Releases the Up Arrow key
      • Player - Player 3 (Teal) Releases the Up Arrow key
      • Player - Player 4 (Purple) Releases the Up Arrow key
      • Player - Player 5 (Yellow) Releases the Up Arrow key
      • Player - Player 6 (Orange) Releases the Up Arrow key
      • Player - Player 7 (Green) Releases the Up Arrow key
      • Player - Player 8 (Pink) Releases the Up Arrow key
      • Player - Player 9 (Gray) Releases the Up Arrow key
      • Player - Player 10 (Light Blue) Releases the Up Arrow key
    • Conditions
    • Actions
      • Set Up_Pressed_Player[(Player number of (Triggering player))] = False
  • Press Down
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
      • Player - Player 2 (Blue) Presses the Down Arrow key
      • Player - Player 3 (Teal) Presses the Down Arrow key
      • Player - Player 4 (Purple) Presses the Down Arrow key
      • Player - Player 5 (Yellow) Presses the Down Arrow key
      • Player - Player 6 (Orange) Presses the Down Arrow key
      • Player - Player 7 (Green) Presses the Down Arrow key
      • Player - Player 8 (Pink) Presses the Down Arrow key
      • Player - Player 9 (Gray) Presses the Down Arrow key
      • Player - Player 10 (Light Blue) Presses the Down Arrow key
    • Conditions
    • Actions
      • Set Down_Pressed_Player[(Player number of (Triggering player))] = True
  • Release Down
    • Events
      • Player - Player 1 (Red) Releases the Down Arrow key
      • Player - Player 2 (Blue) Releases the Down Arrow key
      • Player - Player 3 (Teal) Releases the Down Arrow key
      • Player - Player 4 (Purple) Releases the Down Arrow key
      • Player - Player 5 (Yellow) Releases the Down Arrow key
      • Player - Player 6 (Orange) Releases the Down Arrow key
      • Player - Player 7 (Green) Releases the Down Arrow key
      • Player - Player 8 (Pink) Releases the Down Arrow key
      • Player - Player 9 (Gray) Releases the Down Arrow key
      • Player - Player 10 (Light Blue) Releases the Down Arrow key
    • Conditions
    • Actions
      • Set Down_Pressed_Player[(Player number of (Triggering player))] = False
  • Adjust Camera
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Disable_Cam_For_Arrow_Keys = (Target of (Current camera))
        • Do Multiple ActionsFor each (Integer A) from 1 to 10, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Up_Pressed_Player[(Integer A)] Equal to (==) True
              • Then - Actions
                • Camera - Set (Player((Integer A)))'s camera Distance to target to ((Distance to target of (Current camera)) - 100.00) over 0.30 seconds
                • Camera - Pan camera for (Player((Integer A))) to Disable_Cam_For_Arrow_Keys over 0.00 seconds
                • Custom script: call RemoveLocation(udg_Disable_Cam_For_Arrow_Keys)
              • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Down_Pressed_Player[(Integer A)] Equal to (==) True
              • Then - Actions
                • Camera - Set (Player((Integer A)))'s camera Distance to target to ((Distance to target of (Current camera)) + 100.00) over 0.30 seconds
                • Camera - Pan camera for (Player((Integer A))) to Disable_Cam_For_Arrow_Keys over 0.00 seconds
                • Custom script: call RemoveLocation(udg_Disable_Cam_For_Arrow_Keys)
              • Else - Actions
What it does is it zooms out when you press the down key, zooms in when you press the up key and it doesn't change the position of your camera when the up or down keys are being pressed.

Be carefull: this might not be that acurate right now. Sometimes it takes a small split second before keeping the camera on the same position.
If you want to optimize this you might be better off with Jass.

You might also want to disable left and right arrow keys so that the player must use the mouse to look around. Or you can remove the re-positioning of the camera so that you can also look with arrow keys but that might be anoying for the zoom system.

It's all up to you bro ;)

Just remove the Pan camera, RemoveLocation and Disable_Cam variable if you want to make it possible for the player to change the camera position through arrow keys.

  • Set Disable_Cam_For_Arrow_Keys = (Target of (Current camera))
  • Camera - Pan camera for (Player((Integer A))) to Disable_Cam_For_Arrow_Keys over 0.00 seconds
  • Custom script: call RemoveLocation(udg_Disable_Cam_For_Arrow_Keys)
Also: Change the -100 and +100 to adjust the zoom speed.
  • Camera - Set (Player((Integer A)))'s camera Distance to target to ((Distance to target of (Current camera)) - 100.00) over 0.30 seconds
  • Camera - Set (Player((Integer A)))'s camera Distance to target to ((Distance to target of (Current camera)) + 100.00) over 0.30 seconds
Good luck.

EDIT: I just had an idea... What if you can only zoom after pressing escape and vice versa, making it possible to toggle between camera zoom and camera movement?
If you want this, it should be really simple to implement. I'll give you a hint:
  • Player - Player 1 (Red) skips a cinematic sequence
 
Last edited:
Status
Not open for further replies.
Top