Announcement

Collapse
No announcement yet.

Zoom in speed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Zoom in speed

    So I'm not sure if this was asked before, but is there a way to slow the zoom functionality of a weapon? And I'm not talking about half the zoom speed of a usual zoom, I'm talking about slomo 0.1 zoom speed

    Any inputs/advice would be greatly apprieciated

    Thanks!

    #2
    I do think it's possible because I have seen different zoom speeds before on weapons, though I cannot say how to do it.

    Comment


      #3
      can you specify what weapons you've seen this?

      I just want to understand how they did it, like what event/simulated function they used

      Comment


        #4
        The rate at which the zoom increases for the basic sniper rifle zoom code is all hard coded in the player controller (basically zooms into the max level in a little under a second). So to use a different zoom rate requires the FOV setting code to be in the weapon, and to use either 'weapontick' event or 'renderoverlays' functions (or some other function called every tick) to manually adjust the player FOV (and ensure it is done on the client).

        Here is some untested code snippets (I use some of the below code in my mod, but not the zoom rate...):
        Code:
        var          bool   bAimMode;
        var(EGY)  int      MyFOV;
        var(EGY)  float   ZoomRate;
        var          float   ZoomPct; // used so that clients can smoothly update their offset
        ...
        
        replication{
            //Functions called on the server from the client
            reliable if(Role < ROLE_Authority)
                CheckZoom, ServerForcePVO;
        
            //Functions called on the client from the server
            reliable if(Role == ROLE_Authority)
                ClientForcePVO;
        }
        ....
        exec function CheckZoom(){
             //repClientMessage("exec CheckZoom");
             //PlayOwnedSound(Sound'UMenu.LittleSelect',, Pawn(Owner).SoundDampening);
             if (bAimMode){
                ResetPVO();
                ClientForcePVO(false);
        	    bAimMode=false;
             }else{
                 ZoomPVO();
                 ClientForcePVO(true);
        	     bAimMode=true;
             }
        }
        
        simulated function ZoomPVO(){
            //repClientMessage("exec ZoomPVO");
            if (PlayerController(Instigator.Controller)== none) return;
            //if(bUseScopeView ....){ // add potential conditional checks here to ensure you really want to zoom in...
            // If you want to 'snap' zoom in, execute the three lines below... 
        //        PlayerController(Instigator.Controller).DesiredFOV=MyFOV;
        //        PlayerController(Instigator.Controller).FOVAngle=MyFOV; // this snaps the view forward
        //        DisplayFOV = MyFOV;// <-this line would alter how the weapon model is drawn on screen when zoomed 
            //}
            bAimMode=true;
            ZoomPct=1.0;
        }
        
        simulated function ClientForcePVO(bool bZoom){
          if(Role == ROLE_Authority) return;
          if(bZoom) ZoomPVO();
          else ResetPVO();
        }
        
        function ServerForcePVO(bool bZoom){
           if(bZoom) ZoomPVO();
           else ResetPVO();
        }
        
        // this needs to be called when switching weapons to reset the Player's FOV
        simulated function ResetPVO(){
             local float OldFOV;
             //repClientMessage("ResetPVO");
             if (PlayerController(Instigator.Controller)== none) return;
             OldFOV = PlayerController(Instigator.Controller).DefaultFOV;
             PlayerController(Instigator.Controller).DesiredFOV=OldFOV;
             PlayerController(Instigator.Controller).FOVAngle=OldFOV;
             bAimMode=false;
             ZoomPct=0.0; // <- may not really be necessary since bAimMode is being used....
             //DisplayFOV = OldFOV;
        }
        
        // this should be called on the clients too, but may need to specify it as simulated (I think this 'event' are already executed clientside, but need to verify...
        event WeaponTick(float dt){
             local int NewFOV;
             local PlayerController PC;
        
            super.WeaponTick(dt);
             // only execute if we are aiming and this is a actual human player, and we still have some "zoom" to execute
            if(bAimMode && PlayerController(Instigator.Controller)!= none && ZoomPct > 0.0 )
            {
                ZoomPct -= dt*ZoomRate; // if zoom rate is 1.0 will take a second to zoom in fully, if is 0.5 will take 2 seconds to zoom in etc.
                PC = PlayerController(Instigator.Controller);
                NewFOV = MyFOV + Fmax(0.0, ZoomPct)*(PC.DefaultFOV - MyFOV); // <- this math could probably be optimized
                PC.DesiredFOV=NewFOV;
                PC.FOVAngle=NewFOV;
            }
        }
        
        // You may want to include a call to ResetPVO, and or ServerForcePVO(true/false) in 
        // the ClientStartFire/ClientStopFire functions if you want to use AltFire for zooming/unzooming
        
        simulated function bool PutDown(){
            if( Instigator.Controller.IsA( 'PlayerController' ) ) // two different ways for checking if the owner is a human player
                ResetPVO();
            return Super.PutDown();
        }
        
        simulated function ClientWeaponThrown(){
            if( (Instigator != None) && (PlayerController(Instigator.Controller) != None) )
                ResetPVO();
            Super.ClientWeaponThrown();
        }
        ....
        
        defaultProperties
        {
        ....
            ZoomRate=1.0
            MyFOV=10 // <- 10 degrees, change to whatever zoomed FOV you want.
        }

        Comment


          #5
          You know a cool sniper zoom that I liked was when you pushed the zoom button and then you could zoom in or out by adjusting it with the mouse scroll button.

          Comment

          Working...
          X