• 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.

[General] Camera bounds

Status
Not open for further replies.

sentrywiz

S

sentrywiz

Hi.

I set camera bounds to some region. I make the region as smallest as possible. Then when I go in-game, I notice that even though the region is the smallest, i can still move my camera a little down, left, right and up. Yet I've seen maps in which the camera is unable to move once bound to some region.

How do they do that?
 

sentrywiz

S

sentrywiz

Tried chaosy's suggestion - it works, but not where i want it. the no region is locked to somewhere and then i can't apply the camera i want.

Wietlol - what do you mean a 0x0 region? How can you make such a region?

Dr Super Good - i tried that, doesn't work as well. i can still move the camera a bit. also i checked in other rpg maps, they don't reinforce the camera but just have it bound to a region.
 

sentrywiz

S

sentrywiz

Obviously the "no region" is supposed to be replaced with a region of your choice...

That wasn't obvious at all, since there is a "no region" setting. the bound region allows moving the camera a bit, that was my original question.

I bound the camera to a unit. it works good now.
 

sentrywiz

S

sentrywiz

A 0x0 region is a region where the topleft, topright, bottomleft and bottomright corner are all on the same coordinate.
In essence, a region with 0 width and 0 height (0x0)

that's great, but how do you make one? its probably with jass cuz i haven't been able to make or edit a region to a 0x0.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
-_-

I think we need a proper camera library.

Anyway, if you have JNGP, you can create a trigger, transform it into custom text (JASS script) and place this script into it (removing all other code from that trigger):
JASS:
library Camera

    function ForceCameraOnCoordinate takes real x, real y returns nothing
        call SetCameraBounds(x, y, x, y, x, y, x, y)
    endfunction

    function ForceCameraOnPoint takes location l returns nothing
        call ForceCameraOnCoordinate(GetLocationX(l), GetLocationY(l))
    endfunction
    
    function ForceCameraOnPointForPlayer takes player p, location l returns nothing
        if GetLocalPlayer() == p then
            call ForceCameraOnCoordinate(GetLocationX(l), GetLocationY(l))
        endif
    endfunction
    
    function ForceCameraOnCoordinateForPlayer takes player p, real x, real y returns nothing
        if GetLocalPlayer() == p then
            call ForceCameraOnCoordinate(x, y)
        endif
    endfunction
    
endlibrary

If you dont have JNGP, you just copy the functions (everything except the library Camera and endlibrary tags) and paste it into your header file.
After that you download JNGP 2.0 and praise me for telling you to do so.

Anyway, if you are unfamiliar with GetLocalPlayer() stuff, use ForceCameraOnCoordinateForPlayer() or ForceCameraOnPointForPlayer()
You can use these methods in GUI using a custom script like this:
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set TempLocation[0] = (Position of Paladin 0000 <gen>)
      • Set TempPlayer[0] = (Owner of Paladin 0000 <gen>)
      • Custom script: call ForceCameraOnPointForPlayer(udg_TempPlayer[0], udg_TempLocation[0])
      • Custom script: call RemoveLocation(udg_TempLocation[0])
You need the player and location/coordinate to force the camera on.
Using the function without the "ForPlayer" will do this for all players.
You can reset the camera to the game camera using the normal Reset to game camera GUI action or you can update the position of the camera using this method if you want to.
 

sentrywiz

S

sentrywiz

-_-

I think we need a proper camera library.

Anyway, if you have JNGP, you can create a trigger, transform it into custom text (JASS script) and place this script into it (removing all other code from that trigger):
JASS:
library Camera

    function ForceCameraOnCoordinate takes real x, real y returns nothing
        call SetCameraBounds(x, y, x, y, x, y, x, y)
    endfunction

    function ForceCameraOnPoint takes location l returns nothing
        call ForceCameraOnCoordinate(GetLocationX(l), GetLocationY(l))
    endfunction
    
    function ForceCameraOnPointForPlayer takes player p, location l returns nothing
        if GetLocalPlayer() == p then
            call ForceCameraOnCoordinate(GetLocationX(l), GetLocationY(l))
        endif
    endfunction
    
    function ForceCameraOnCoordinateForPlayer takes player p, real x, real y returns nothing
        if GetLocalPlayer() == p then
            call ForceCameraOnCoordinate(x, y)
        endif
    endfunction
    
endlibrary

If you dont have JNGP, you just copy the functions (everything except the library Camera and endlibrary tags) and paste it into your header file.
After that you download JNGP 2.0 and praise me for telling you to do so.

Anyway, if you are unfamiliar with GetLocalPlayer() stuff, use ForceCameraOnCoordinateForPlayer() or ForceCameraOnPointForPlayer()
You can use these methods in GUI using a custom script like this:
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set TempLocation[0] = (Position of Paladin 0000 <gen>)
      • Set TempPlayer[0] = (Owner of Paladin 0000 <gen>)
      • Custom script: call ForceCameraOnPointForPlayer(udg_TempPlayer[0], udg_TempLocation[0])
      • Custom script: call RemoveLocation(udg_TempLocation[0])
You need the player and location/coordinate to force the camera on.
Using the function without the "ForPlayer" will do this for all players.
You can reset the camera to the game camera using the normal Reset to game camera GUI action or you can update the position of the camera using this method if you want to.

Great to know, but waaaay easier to just use an invisible unit or even deal with the slight movement of the camera.
 
Level 1
Joined
Jan 24, 2014
Messages
6
My solution

There is solution based on "Lock camera target to unit".
Copy Dummy unit and trigger "Test Trigger", remove "Message for Player" action.
Also config Test Trigger to use my Dummy unit, set his position to needed position and Expiration timer to needed value (you may remove this action and kill unit using triggers also).
 
Last edited:

sentrywiz

S

sentrywiz

There is solution based on "Lock camera target to unit".
Copy Dummy unit and trigger "Test Trigger", remove "Message for Player" action.
Also config Test Trigger to use my Dummy unit, set his position to needed position and Expiration timer to needed value (you may remove this action and kill unit using triggers also).

Okay, though this is the solution I used anyway.

Can you actually kill the unit your camera is bound to? That wouldn't accomplish anything if the unit is invisible anyway.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Okay, though this is the solution I used anyway.

Can you actually kill the unit your camera is bound to? That wouldn't accomplish anything if the unit is invisible anyway.

Yes, since you'd use a "lock camera periodic system" thing, you'd use an invisible dummy.
Yet, if the dummy is removed, the camera will be unlocked.
If the dummy dies, the camera will still be locked because the unit exists, while it is not alive.
 

sentrywiz

S

sentrywiz

Yes, since you'd use a "lock camera periodic system" thing, you'd use an invisible dummy.
Yet, if the dummy is removed, the camera will be unlocked.
If the dummy dies, the camera will still be locked because the unit exists, while it is not alive.

That's cool to know.
 
Status
Not open for further replies.
Top