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

[JASS] Current Camera Bounds?

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
Hey guys,

i wanted to create a function, that locks the game camera for player x to the middle of his current camera bounds (the place where he is looking at).

So i created a dummy at map initialisation at Location (0,0)

The Problem is, the functions doesnt set the unit x and y to the new values, it always locks the game cam at (0,0)

JASS:
function AdjustCameraForPlayer takes player p returns nothing
    
    local rect r
    local integer id = GetPlayerId(p)
     
    if GetLocalPlayer() == p then
       set r = Rect(GetCameraBoundMinX(),GetCameraBoundMinY(),GetCameraBoundMaxX(),GetCameraBoundMaxY())
       call SetUnitX(udg_Spielheld[id+5],GetRectCenterX(r))
       call SetUnitY(udg_Spielheld[id+5],GetRectCenterY(r))
       
       call SetCameraTargetController(udg_Spielheld[id+5],0.00,0.00,false)
    endif
    
endfunction

So my question is, how can i get the current camera field of player x?

Thanks :)
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
no there isnt, and why dont you open another thread for this? it doesnt relate to my question -.-!

@topic:
I want to do this :

get the x and y of the CENTER of the actual game view of player x to lock the camera there!

Therefore i thought about creating a rect and getting its center.

this is the new code btw:
JASS:
function AdjustCameraForPlayer takes player p returns nothing
    
    local integer id = GetPlayerId(p)
     
    if GetLocalPlayer() == p then
    
       call SetUnitX(udg_Spielheld[id+5],GetCameraBoundMaxX()-GetCameraBoundMinX())
       call SetUnitY(udg_Spielheld[id+5],GetCameraBoundMaxY()-GetCameraBoundMinY())
       
       call SetCameraTargetController(udg_Spielheld[id+5],0.00,0.00,false)
    endif
    
endfunction

the problem is:

The camera is NOT locked at the right x/y. it always locks the cam at (0,0) or at the top right corner of the map.
So how can i get the real current camera bounds? I mean, the actual game view of player x?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
well thanks ghost, you cleared the mathematical failure of mine.

I tried this new thing
JASS:
call SetUnitX(udg_Spielheld[id+5],(GetCameraBoundMaxX()+GetCameraBoundMinX())/2)
       call SetUnitY(udg_Spielheld[id+5],(GetCameraBoundMaxY()+GetCameraBoundMinY()(/2)
       
       call SetCameraTargetController(udg_Spielheld[id+5],0.00,0.00,false)

and it moves the dummy to the location (0/0), to the middle of the map.

That means, the camera bounds are not the place where the player is looking at?!

Am i wrong, or if im not, is there any way to do, what i want?

just once again: i want to freeze the camera for player x
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
i already did it, the CameraBound-Values are always the same values.

And if i change them with
JASS:
SetCameraBounds()
, the minimap gets ugly, as we all know ^^

So how can i freeze the camera for player x without pausing the game?

I could show a dialog without any buttons, but i dont want to pause the game for player x neither...i just want to lock the camera to the place where he is looking at

Please help :)
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
yessss

Thanks justify,
JASS:
GetCameraTargetPositionX()
GetCameraTargetPositionY()
was exactly what i needed.

@Famouspoker: i want to freeze the camera at its current point.

[Porblem solved]

Thanks at all who tried to help me, and of course some rep for you guys :D
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Those functions only work for one player, so for them to work in multiplayer, you'll need a bit of local player poop:
JASS:
    local real x
    local real y
    if (GetLocalPlayer() == Player(0)) then
        set x = GetCameraTargetPositionX()
        set y = GetCameraTargetPositionY()
        // Do stuff or something idk
    endif
That will set x and y to the camera target position of Player(0) (red) in multiplayer.
 
Status
Not open for further replies.
Top