Results 1 to 12 of 12
  1. #1
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Exclamation Toggling Variable not working

    I was able to successfully toggle between Isometric Camera and Third Person from the All In One Camera. I've customized the third camera so it's alittle back then when you press T for instance, it will go back to the Over The Shoulder Aiming Style. I've looked over the code several times and still question myself, "How hard is it to toggle on and off a variable?"

    this is my custom pawn class. As you see I'm trying to toggle AimOn.
    Code:
    var float CameraDistance; //Position on Y-axis to lock camera to
    var int IsoCamAngle; //pitch angle of the camera
    
    var input bool AimOn;
    
    
    //override to make player mesh visible by default
    simulated event BecomeViewTarget( PlayerController PC )
    {
       local SICPlayerController UTPC;
    
       Super.BecomeViewTarget(PC);
    
       if (LocalPlayer(PC.Player) != None)
       {
          UTPC = SICPlayerController(PC);
          if (UTPC != None)
          {
             //set player controller to behind view and make mesh visible
             UTPC.SetBehindView(true);
             SetMeshVisibility(UTPC.bBehindView);
             UTPC.bNoCrosshair = false;
          }
       }
    }
    
    
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
     
      local vector CamStart, HitLocation, HitNormal, CamDirX, CamDirY, CamDirZ, CurrentCamOffset;
       local float DesiredCameraZOffset;
    
       CamStart = Location;
      
     
       
       CurrentCamOffset = CamOffset;
    if(AimOn !=true) {
    
       CurrentCamOffset.X += CameraDistance;
    }
    
       
       DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z - 2 : 0.f;
       CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
       
       if ( Health <= 0 )
       {
          CurrentCamOffset = vect(0,0,0);
          CurrentCamOffset.X = GetCollisionRadius();
       }
    
       CamStart.Z += CameraZOffset;
       GetAxes(out_CamRot, CamDirX, CamDirY, CamDirZ);
       CamDirX *= CurrentCameraScale;
       
       
       if ( (Health <= 0) || bFeigningDeath )
       {
          // adjust camera position to make sure it's not clipping into world
          // @todo fixmesteve.  Note that you can still get clipping if FindSpot fails (happens rarely)
          FindSpot(GetCollisionExtent(),CamStart);
       }
       if (CurrentCameraScale < CameraScale)
       {
          CurrentCameraScale = FMin(CameraScale, CurrentCameraScale + 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
       }
       else if (CurrentCameraScale > CameraScale)
       {
          CurrentCameraScale = FMax(CameraScale, CurrentCameraScale - 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
       }
    
       if (CamDirX.Z > GetCollisionHeight())
       {
          CamDirX *= square(cos(out_CamRot.Pitch * 0.0000958738)); // 0.0000958738 = 2*PI/65536
       }
    
       out_CamLoc = CamStart - CamDirX*CurrentCamOffset.X + CurrentCamOffset.Y*CamDirY + CurrentCamOffset.Z*CamDirZ;
    
       if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
       {
          out_CamLoc = HitLocation;
       }
    
       return true;
       
    /*    out_CamLoc = Location;
       out_CamLoc.X -= Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
       out_CamLoc.Z += Sin(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
    
       out_CamRot.Pitch = -1 * IsoCamAngle;   
       out_CamRot.Yaw = 0;
       out_CamRot.Roll = 0;
    
       return true; */
       
    }
    
    
    defaultproperties
    {
    AimOn = false;
       
       CameraDistance=17;
       
    }
    in the defaultinput.ini I have T key bind to toggle the AimOn.

    Code:
    .Bindings=(Name="T",Command="Toggle AimOn")
    I also tried a seperate exec function using the toggle keybind technique.

    Any idea?
    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios

  2. #2
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    What is Toggle AimOn..?

  3. #3
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Default

    Quote Originally Posted by VendorX View Post
    What is Toggle AimOn..?
    in the keybind technical it toggles a variable

    http://udn.epicgames.com/Three/KeyBinds.html#Toggle
    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios

  4. #4
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    "This allows to automatically create a toggle using a byte as the target variable. The variable should be defined as:
    var input byte bLook; // Where bLook is the name of the variable"

    ...and you have? Maybe this don't work on bool...

  5. #5
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Default

    I'm not sure if I have to hook the PlayerController inside the MyCustomPawn.UC in order for the key bind to work. However, it should work because all I'm doing is adjusting the camera distance variable. So, I created two exec functions.

    Code:
    
    exec function AimingOn() {
    CameraDistance = 17.0;
    
    }
    exec function AimingOff() {
    CameraDistance = 0.0;
    
    }
    Also adjusted the defaultinput.ini file like so:

    Code:
    .Bindings=(Name="SwitchAimOn", Command="AimingOn | SetBind T SwitchAimOff")
    .Bindings=(Name="SwitchAimOff", Command="AimingOff | SetBind T SwitchAimOn")
    
    .Bindings=(Name="T",Command="SwitchAimOn")
    Yet no can do. I'm going to put the exec functions inside the custom playercontroller and see what happens.
    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios

  6. #6
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Try this:
    Code:
    var bool bAimOn;
    
    exec function SwitchAimOn()
    {
    	bAimOn = !bAimOn;	// here is your switch...
    }
    and...

    Code:
    Bindings=(Name="T",Command="SwitchAimOn")
    That dot before Bindings shouldn't be there.
    Last edited by VendorX; 02-14-2012 at 05:47 PM.

  7. #7
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Default

    Nope, sadly it does not. I've made changes and took samples from the All In One Camera from the Camera Technical Guide on UDN. Before, I was able to Toggle the T key to switch different camera types. So, the various of changes were made and still having a no luck.

    MyCustomPawn.uc file

    Code:
    Enum AimPerspective
    {
       AIM_Normal,
       AIM_OverShoulder
       };
    
    var bool bFollowPlayerRotation;
    var AimPerspective AimType;
    
    exec function AimingMode(AimPerspective mode)
    {
       local SICPlayerController UTPC;
    
       AimType = mode;
    
       UTPC = SICPlayerController(Controller);
       
          
       if (UTPC != None)
       {
             UTPC.SetBehindView(true);
       
          SetMeshVisibility(UTPC.bBehindView);
       }
    }
    
    
    /* BecomeViewTarget
       Called by Camera when this actor becomes its ViewTarget */
    simulated event BecomeViewTarget( PlayerController PC )
    {
       local SICPlayerController UTPC;
    
       Super.BecomeViewTarget(PC);
    
       if (LocalPlayer(PC.Player) != None)
       {
          UTPC = SICPlayerController(PC);
          if (UTPC != None)
          {
            
                UTPC.SetBehindView(true);
            
             SetMeshVisibility(UTPC.bBehindView);
          }
       }
    }
    
    /**
     *   Calculate camera view point, when viewing this pawn.
     *
     * @param   fDeltaTime   delta time seconds since last update
     * @param   out_CamLoc   Camera Location
     * @param   out_CamRot   Camera Rotation
     * @param   out_FOV      Field of View
     *
     * @return   true if Pawn should provide the camera point of view.
     */
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
       // Handle the fixed camera
    
          if ( AimType == AIM_Normal )   // Handle BehindView
          {
             CalcNormalCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
          }
        
          else if ( AimType == AIM_OverShoulder )   // Handle BehindView
          {
             CalcOverShoulderCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
          }
         
    
        
      
       return true;
    }
    
    
    simulated function bool CalcNormalCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
      local vector CamStart, HitLocation, HitNormal, CamDirX, CamDirY, CamDirZ, CurrentCamOffset;
       local float DesiredCameraZOffset;
    
       CamStart = Location;
      
     
       
       CurrentCamOffset = CamOffset;
    
      
     
       
       CurrentCamOffset.X += CameraDistance;
    
    
    
       
       DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z - 2 : 0.f;
       CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
       
       if ( Health <= 0 )
       {
          CurrentCamOffset = vect(0,0,0);
          CurrentCamOffset.X = GetCollisionRadius();
       }
    
       CamStart.Z += CameraZOffset;
       GetAxes(out_CamRot, CamDirX, CamDirY, CamDirZ);
       CamDirX *= CurrentCameraScale;
       
       
       if ( (Health <= 0) || bFeigningDeath )
       {
          // adjust camera position to make sure it's not clipping into world
          // @todo fixmesteve.  Note that you can still get clipping if FindSpot fails (happens rarely)
          FindSpot(GetCollisionExtent(),CamStart);
       }
       if (CurrentCameraScale < CameraScale)
       {
          CurrentCameraScale = FMin(CameraScale, CurrentCameraScale + 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
       }
       else if (CurrentCameraScale > CameraScale)
       {
          CurrentCameraScale = FMax(CameraScale, CurrentCameraScale - 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
       }
    
       if (CamDirX.Z > GetCollisionHeight())
       {
          CamDirX *= square(cos(out_CamRot.Pitch * 0.0000958738)); // 0.0000958738 = 2*PI/65536
       }
    
       out_CamLoc = CamStart - CamDirX*CurrentCamOffset.X + CurrentCamOffset.Y*CamDirY + CurrentCamOffset.Z*CamDirZ;
    
       if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
       {
          out_CamLoc = HitLocation;
       }
    
       return true;
      
    }
    
    
    simulated function bool CalcOverShoulderCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
      local vector CamStart, HitLocation, HitNormal, CamDirX, CamDirY, CamDirZ, CurrentCamOffset;
       local float DesiredCameraZOffset;
    
       CamStart = Location;
      
     
       
       CurrentCamOffset = CamOffset;
    
      
     
       
    
       
       DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z - 2 : 0.f;
       CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
       
       if ( Health <= 0 )
       {
          CurrentCamOffset = vect(0,0,0);
          CurrentCamOffset.X = GetCollisionRadius();
       }
    
       CamStart.Z += CameraZOffset;
       GetAxes(out_CamRot, CamDirX, CamDirY, CamDirZ);
       CamDirX *= CurrentCameraScale;
       
       
       if ( (Health <= 0) || bFeigningDeath )
       {
          // adjust camera position to make sure it's not clipping into world
          // @todo fixmesteve.  Note that you can still get clipping if FindSpot fails (happens rarely)
          FindSpot(GetCollisionExtent(),CamStart);
       }
       if (CurrentCameraScale < CameraScale)
       {
          CurrentCameraScale = FMin(CameraScale, CurrentCameraScale + 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
       }
       else if (CurrentCameraScale > CameraScale)
       {
          CurrentCameraScale = FMax(CameraScale, CurrentCameraScale - 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
       }
    
       if (CamDirX.Z > GetCollisionHeight())
       {
          CamDirX *= square(cos(out_CamRot.Pitch * 0.0000958738)); // 0.0000958738 = 2*PI/65536
       }
    
       out_CamLoc = CamStart - CamDirX*CurrentCamOffset.X + CurrentCamOffset.Y*CamDirY + CurrentCamOffset.Z*CamDirZ;
    
       if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
       {
          out_CamLoc = HitLocation;
       }
    
       return true;
      
    }
    
    
    
    defaultproperties
    {
       AimType=AIM_Normal;
       
       CameraDistance = 17;
       
    }
    MyCustomPlayerController.uc

    Code:
    state PlayerWalking
    {
    
      function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
       {
          local SICPawn P;
          // local Rotator tempRot;
    
              if( (P != None) )
          {
             P = SICPawn(Pawn);
          }
          
          if (Role == ROLE_Authority)
          {
             // Update ViewPitch for remote clients
             Pawn.SetRemoteViewPitch( Rotation.Pitch );
          }
    
          Pawn.Acceleration = NewAccel;
    
          CheckJumpOrDuck();
        
       }
    
    }
    function UpdateRotation( float DeltaTime )
    {
       local Rotator   DeltaRot, newRotation, ViewRotation;
    
       
       local SICPawn P;
       
       P = SICPawn(Pawn);
    
       ViewRotation = Rotation;
       if (p != none)
       {
          P.SetDesiredRotation(ViewRotation);
       }
    
       // Calculate Delta to be applied on ViewRotation
       DeltaRot.Yaw   = PlayerInput.aTurn;
       DeltaRot.Pitch   = PlayerInput.aLookUp;
    
       ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
       SetRotation(ViewRotation);
    
       NewRotation = ViewRotation;
       NewRotation.Roll = Rotation.Roll;
    
       if ( P != None )
          P.FaceRotation(NewRotation, deltatime);
    
       ViewShake( deltaTime );
    
     
    }
    
    defaultproperties
    {
    }
    I've looked tightly into this situation and found no reason that there should be ever a problem. I am using January 2012 UDK version, however unlikely this KeyBinding issue would to be the blame for the January version. If anyone had have some insight - be kind to share. This is puzzling more than a rubic's cube.
    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios

  8. #8
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Default

    Forgot to mention the adjustment to defaultinput.ini

    Code:
    .Bindings=(Name="SwitchAimOn", Command="AimingMode 1 | SetBind T SwitchAimOff")
    .Bindings=(Name="SwitchAimOff", Command="AimingMode 0 | SetBind T SwitchAimOn")
    
    .Bindings=(Name="T",Command="SwitchAimOn")
    1 is AIM_Normal

    2 is AIM_OverShoulder

    I found that in my previous successful attempt by cycling cameras that I was able to just use with the name or a number.
    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios

  9. #9
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    This is the last time...

    GameInfo:
    Code:
    class TestDeathmatch extends UTDeathmatch;
    
    defaultproperties
    {
    	PlayerControllerClass=class'ScriptTest.TestPlayerController'
    }
    PlayerController:
    Code:
    class TestPlayerController extends UTPlayerController;
    
    var bool bAimOn;
    
    exec function SwitchAimOn()
    {
    	bAimOn = !bAimOn;	// here is your switch...
    	SetBehindView(bAimOn);
    }
    
    defaultproperties
    {
    }
    Bindings:
    Code:
    Bindings=(Name="T",Command="SwitchAimOn")
    Code is from my post #6. Simple switch BehindView. Try adp and put some logs to be sure, that your code do what you want.
    ...and don't tell me that this way not work, because i've tested.

    BTW. Problem is in your head - read the posts more carefully and don't add that F*** dot before Bindings
    Last one thing - live alone defaultinput.ini, use UDKInput.ini.
    Last edited by VendorX; 02-15-2012 at 06:01 AM.

  10. #10
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Default

    I think you've been patient and you would like to be rewarded. Here's the demo release of the Aiming Style feature. This kind of reminds me of GTA kind of Aiming feature, doesn't it? I imagine my custom pawn walking, when he or she is ready to pull out weapon - the crosshair will show and it will switch to the aiming mode style. In correction to your code; what your code was doing was switching between 3rd person and first person. The CalcCamera function - didn't support the First Person point of view because it was strictly only for 3rd person. If it had, I would have to set a function GetPlayerEyes or something. Still, on the right idea and with your dedicated effort - this helped me achieve the goal I was aiming for. No pun intended. All I was after was toggling the true and false then in setting up the function CalcCamera to figure out what to do about the camera's offset.

    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios

  11. #11
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    You see... I could write this code in my first post, but in this way probably you will never know how this work.
    Happy to help.

  12. #12
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    The Haunted Basement.
    Posts
    37

    Default

    Quote Originally Posted by VendorX View Post
    You see... I could write this code in my first post, but in this way probably you will never know how this work.
    Happy to help.
    :P You know there was no necessary need to put the SwitchAim in the PlayerController. PlayerController only deals with updating with processing the pawn's rotation and the movement. :P But you're still awesome!
    Success is building firm bold foundation towards your desire goal.

    Easily Watch New Demos & Learn Great Tutorials Right Here http://www.youtube/com/user/6ICGameStudios


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.