Jump to content

Zoom only first person camera


Recommended Posts

In default.bind.cs you have this bunch of functions and settings.


You could add a check in the camera toggle function which I don't think I've posted, or you could check the camera mode inside of the FoV function, i'd probably do the former, but each game is different.

 

//------------------------------------------------------------------------------
// Zoom and FOV functions
//------------------------------------------------------------------------------

if($Player::CurrentFOV $= "")
  $Player::CurrentFOV = $pref::Player::DefaultFOV / 2;

// toggleZoomFOV() works by dividing the CurrentFOV by 2.  Each time that this
// toggle is hit it simply divides the CurrentFOV by 2 once again.  If the
// FOV is reduced below a certain threshold then it resets to equal half of the
// DefaultFOV value.  This gives us 4 zoom levels to cycle through.

function toggleZoomFOV()
{
   $Player::CurrentFOV = $Player::CurrentFOV / 2;

   if($Player::CurrentFOV < 5)
       resetCurrentFOV();

   if(ServerConnection.zoomed)
     setFOV($Player::CurrentFOV);
   else
   {
     setFov(ServerConnection.getControlCameraDefaultFov());
   }
}

function resetCurrentFOV()
{
  $Player::CurrentFOV = ServerConnection.getControlCameraDefaultFov() / 2;
}

function turnOffZoom()
{
  ServerConnection.zoomed = false;
  setFov(ServerConnection.getControlCameraDefaultFov());
  Reticle.setVisible(true);
  zoomReticle.setVisible(false);

  // Rather than just disable the DOF effect, we want to set it to the level's
  // preset values.
  //DOFPostEffect.disable();
  ppOptionsUpdateDOFSettings();
}

function setZoomFOV(%val)
{
  if(%val)
     toggleZoomFOV();
}

function toggleZoom(%val)
{
  if (%val)
  {
     ServerConnection.zoomed = true;
     setFov($Player::CurrentFOV);
     Reticle.setVisible(false);
     zoomReticle.setVisible(true);

     DOFPostEffect.setAutoFocus( true );
     DOFPostEffect.setFocusParams( 0.5, 0.5, 50, 500, -5, 5 );
     DOFPostEffect.enable();
  }
  else
  {
     turnOffZoom();
  }
}

function mouseButtonZoom(%val)
{
  toggleZoom(%val);
}

moveMap.bind(keyboard, f, setZoomFOV); // f for field of view
moveMap.bind(keyboard, z, toggleZoom); // z for zoom
moveMap.bind( mouse, button1, mouseButtonZoom );

Link to post
Share on other sites

The problem here is probably, that there is no first or third person camera and there is just a camera, the only difference is the position of the camera.


So you could duplicate the camera and call one first person camera and one third person camera and then make the FOV function only change one of those.


Another probably not so nice solution is to just reset the FOV if you switch to third person again, you have to test it to see if the lag is tolerable, but the same problem probably exists if you do the other solution.


It depends more on your specific scenario, which I don't know about yet, but I can imagine you zoom aim with a gun in first person and you don't like that it also zooms in third person so you don't want that, since I had the similar issue, but ignored it for now. For that scenario you could try blocking the zoom function in the weapon for third person view.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...