Locking Cameras

shadowmapper

New Member
Reaction score
0
Basically I need to lock custom cameras, so that the player cannot adjust the camera at all. The camera is generally locked to a fixed unit (invisible dummy unit). Right now I'm using a trigger which executes every .5 seconds of the game and applies the camera and locks it to the dummy unit if the player has entered a region with a locked camera (say, a building interiors).

The cameras and their unit focuses are declared as global variables during initialization (camera array, unit array) and when the unit enters the a region with a locked camera, a Boolean variable (array) is set to true, meeting the 'if' statement conditions for whatever integer in the array the region corresponds too, and then setting the corresponding camera and unit to be locked.

To clarify, I don't want to just limit the field of view, I want to prevent the user from zooming in or out with the mouse wheel, basically from adjusting the camera at all.

Locking the camera to the player's main unit is also not an option here for various reasons.

The trigger is GUI generated and seems to be working fine, just wondering if there is a better way to do this, as executing the trigger every .5 seconds of the game may cause memory issues on other systems, I really don't know. Any comment on this would be appreciated too.
 
Try this:
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope Camlock initializer InitTrig

globals
    //trigger CamLock
    integer INDEX = 0
    boolean array DEAD
    unit array HERO
    player array PLAYERS
    integer array IND
    //location LOC
endglobals

//private function Actions takes nothing returns nothing
//local integer index = 0
//local real x
//local real y
//local real z

//loop
    //exitwhen index == INDEX
    //set x = GetUnitX(HERO[index])
    //set y = GetUnitY(HERO[index])
    //call MoveLocation(LOC,x,y)

    //if GetLocalPlayer() == PLAYERS[index] then
        //if udg_Inventory_Player_Is_Viewing[index] == false then

            //if DEAD[index] == false then
            //set z = GetCameraField(CAMERA_FIELD_ZOFFSET)+300 - (256- GetLocationZ(LOC))-GetCameraTargetPositionZ()
            //call SetCameraField(CAMERA_FIELD_ZOFFSET,z,1.0)
            //call SetCameraPosition(x,y)
            //call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE,1850,0.1)
            //call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK,315,0.1)
            //call SetCameraField(CAMERA_FIELD_ROTATION,140,0.1)

            //endif
        //endif
    //endif
    //set index = index + 1
//endloop
//endfunction

private function InitTrig takes nothing returns nothing
    //set CamLock = CreateTrigger()
    //set LOC = Location(0,0)
    set DEAD[0] = false
    set DEAD[1] = false
    set DEAD[2] = false
    set DEAD[3] = false
    set DEAD[4] = false
    set DEAD[5] = false
//call TriggerRegisterTimerEvent(CamLock,0.2,true)
//call TriggerAddAction(CamLock, function Actions)
endfunction


endscope
 
Thanks for the reply. Unfortunately I think that code is a little over my head... will I be able to set different camera attributes (i.e. target distance, angle of attack, rotation) for respective locations? If so it looks like I could at least take the stats off my cameras and then apply them to the script... but as I said, it's too advanced for me at the moment, but it's good study material xD

FYI Here's the GUI script I'm using now...

Trigger:
  • CAMERA LOCK
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CAMERA_Locked[(Integer A)] Equal to True
            • Then - Actions
              • Camera - Apply CAMERA_LockedCameras[(Integer A)] for Player 1 (Red) over 0.00 seconds
              • Camera - Lock camera target for Player 1 (Red) to CAMERA_FocusPoints[(Integer A)], offset by (0.00, 0.00) using Default rotation
            • Else - Actions
              • Do nothing


As I said CAMERA_LockedCameras and CAMERA_FocusPoints are set at initialization, although I'm thinking now I could just set/change them just before CAMERA_Locked is set to True, which is usually when a unit enters a region, eliminating the loop.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top