Announcement

Collapse
No announcement yet.

Limit Camera Pitch Rotation

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

    Limit Camera Pitch Rotation

    Hey,

    I want to limit my Camera pitch view rotation to a minimum and maximum ?

    So my character can only look down a certain amount?

    Here is my camera class I can't find anything on this any help would be greatly appreciated

    Code:
    simulated function bool CalcCamera(float FDeltaTime, out vector Out_CamLoc, out rotator Out_CamRot, out float Out_FOV)
    {
    local vector hitloc, hitnrm, endpoint;
    
    endpoint = Location - (vector(Controller.Rotation) * -20);
    trace(hitloc, hitnrm, location, endpoint);
    
    if(hitloc == vect(0,0,0)) 
    Out_CamLoc = endpoint;
    else
    Out_CamLoc = location + normal(hitloc) * (vsize(hitloc - location) - 50);
    
    Out_CamRot = Controller.Rotation;
    
    Out_CamLoc.Z += 50;
    
    return true;
    }
    .

    #2
    If you only need to limit the pitch on the camera, then you just need to add something like this:

    Code:
    Out_CamRot.Pitch = Clamp(Out_CamRot.Pitch,-12384,3000);
    Put that line after Out_CamRot = Controller.Rotation. The numbers listed above worked for me for a 3rd person camera I made once that wouldn't look straight up or straight down, but feel free to play around with it until you get limits that you like.

    Also, you might want to consider limiting Controller.Rotation instead. I don't know what kind of game you're making, but letting the controller keep rotating while the camera stays put might mess some things up.

    Comment


      #3
      Thanks ! How would I go about limiting the controller.Rotation ? Controller.Rotation= Clamp(Out_CamRot.Pitch,-12384,3000); ?

      Comment


        #4
        Never Mind Thank you but I solved it!

        ViewPitchMin = -16000
        ViewPitchMax = 14000

        Comment

        Working...
        X