Announcement

Collapse
No announcement yet.

Tips on changing the camera system

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

    Tips on changing the camera system

    Ok, so I’ve got an idea for a mod that will keep my brain busy for a while, and also gives me a great opportunity to learn UScript.

    The first thing on my list is to modify the camera, so that it is in 3rd person, and spins round the player when they move the cursor to the edge of the screen, similar in style to games like Incubation.

    I’m not looking for a "do A, B and C" answer, just pointers to say which packages I should be looking in, and any special bits of code I should be paying attention to, so I can learn as I’m doing.

    Thanks in advance

    Xeno

    #2
    PlayerCalcView in the PlayerController class, and I take it by 'cursor' you mean pointy-clicky thing? You could have invisible buttons at the edges of your menu and I think the function is OnWatch(), you can use that to increment a rotation in the PlayerController (which is kept in the menu as PlayerOwner() ).

    Comment


      #3
      Problem is having menus open and the game open is really messy. If you wanted to hijack the GUI cursor for HUD input, and still be able to move around in the game, you would (I think) run into problems. For instance, GUI is always drawn last, and accepts input first. So to play the game you have to have the GUI send the input to the player, which is backwards and a lot more work.

      A better way, imo, is to hijack the input from the PlayerController and send it to the HUD, which will control where it is drawing the "cursor" (which you have to make). You can then have "buttons" drawn on the HUD and they tell whether or not the "cursor" is on top of them or not, and it all recieves clicks when the player fires, and each button checks if it was clicked, etc. I described this system once before in this thread:

      http://www.ina-community.com/forums/...hreadid=461334

      For rotating when you hit the screen edge, you can simply detect the x, y coordinates of your "curosor" and rotate the camera as desired.

      Comment


        #4
        Ok, thanks people, ill start looking into that.

        Comment


          #5
          Ok so I've got my mouse set up and its moving around great(with help from THIS tutorial), problem is i cant find that values that i should check to see when its touching the sides of the screen.

          With my current code, the camera makes one movement jump after moving the cursor about halfway across the screen, and i still cant figure out how to get it to rotate round the pawn.


          Heres the code in my custom player controller so far.

          Code:
          class CustomPlayer extends PlayerController;
          
          var vector PlayerMouse;
          
          var float LastHUDSizeX;
          var float LastHUDSizeY;
          
          var int iScrollSensitivity;
          
          var bool bRotLeft;
          var bool bRotRight;
          
          state PlayerMousing
          {
           function BeginState()
           {
            bBehindView = true;
            bFreeCamera = true;
            bFreeCamSwivel = true;
           }
          
           exec function Fire(float f)
           {
          
            //Stuff for when player presses fire.
          
            return;
          
           }
          
           simulated function PlayerMove(float DeltaTime)
           {
            local vector MouseV, ScreenV;
          
            //get the new mouse position offset
            mouseV.X = DeltaTime * aMouseX / (InputClass.default.MouseSensitivity * DesiredFOV * 0.005);
            mousev.Y = DeltaTime * aMouseY / (InputClass.default.MouseSensitivity * DesiredFOV * -0.005);
          
            //update mouse position
            PlayerMouse += MouseV;
          
            if ((LastHUDSizeX > 0) && (LastHUDSizeY > 0))
            {
               ScreenV.X = PlayerMouse.X + LastHUDSizeX * 0.5;
               ScreenV.Y = PlayerMouse.Y + LastHUDSizeY * 0.5;
          
               if (PlayerMouse.x <= iScrollSensitivity)
               {
          
                bRotLeft = true;
                bRotRight = false;
          
               }
               else if (Playermouse.X >= (LastHUDSizeX - iScrollSensitivity))
               {
                  bRotLeft = false;
                  bRotRight = true;
               }
               else
               {
                   bRotLeft = false;
                   bRotRight = false;
               }
          
            }
          
            return;
          
           }
          
          
          }
          
            function event PlayerCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )
            {
          
               Super.PlayerCalcView( ViewActor, CameraLocation, CameraRotation );
          
               if (IsInState('PlayerMousing'))
               {
          
                if (bRotLeft)
                 {
          
                 cameralocation.x+=50;
                 camerarotation = viewactor.Rotation;
          
                 }
          
                 if (bRotRight)
                 {
          
                 cameralocation.x-=50;
                 camerarotation = viewactor.Rotation;
                 }
          
          
          
          
          
               }
          
          
          
          
            }
          
          exec function StartMouseTest()
          {
          
          GoToState('PlayerMousing');
          
          }
          
          exec function EndMouseTest()
          {
          
          GoToState('PlayerWalking');
          
          }
          
          
          
          defaultproperties
          {
          
          iScrollSensitivity = 1
          
          }

          Comment


            #6
            Okay, let me help a bit.

            First off, think with me for a second. ScreenV.X and ScreenV.Y are pixel positions on the screen where the mouse will appear (should probably be centered here or wherver the tip of the mouse is, so take notice when drawing the cursor). So you can check those two values (X for left/right, Y for up/down) and flag the camera to move wherever (doesnt really have to be bools, it could be an integer as well 0=off, 1=right, -1=left, but thats up to you). You will know when you are on the left edge of the screen when ScreenV.X <= 0, and when you are on the right edge ScreenV.X >= LastHUDSizeX (Assuming LastHUDSizeX is actually correctly set to the X resolution of the screen). The same applies for the Y. Very simple here.

            Now, once you hit the edge, you have to move your camera around the ViewActor. To do this, you need to override PlayerCalcView (not just call the super and change some stuff, completely override it, its more effecient).

            I'm too tired now to think about vectors (been doing missile seek code all day and my brain is fried, lol), but if you experiment with it, you should be able to figure it out. What you really need to do is, if move left, just move the camera along its -x axis (GetAxes) keeping the radius from the ViewActor and CameraLocation the same, and then adjust the CamRotation to face the ViewActor (should point along the radius). Just move a small amount per calc view, and it will look smooth.

            Comment

            Working...
            X