The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

UDK action game - 3rd person camera code

  • Filter
  • Time
  • Show
Clear All
new posts

    Great Codes, work right away!!! Thank you very much

    Edit: I have a question. How can i control the distance between the cam and the character? Since i dont want the camera to zoom out to much.

    One more thing, when zoom in, the camera seem to zoom over the character, what can i do to make it zoom in the character?


      Hey, I was just wondering if anyone knows a simple way of making the pawn turn to follow the camera instead of using the arrow keys without changing key bindings, although adding them is OK.


        You could just go and do it in kismet in like 10 seconds. And it will look much more dynamic.


          I've been trying to get this working for a while, but for some reason the Script Compiler that runs when you start UDK can't extend UTPawn or UTPlayerController. I use Visual Studio 2010, which has all the Development > Src folders in it's scope. (Including UTGame which has the UT classes)

          I'm pretty new to UDK and Unreal Script, so was wondering if I was doing anything wrong? I also assume that since the script extends the default one, the 3rd person movement should just work if the script compiles correctly?


            Ok, so I'm very new to working with unrealscript (and programming all together) and I'm having troubles with getting this code to work. My knowlage extends up to the few tutorials I read a couple days ago. So yeah, I'm new. And yes I read through all 16 pages but couldn't find my answer.

            I first tried syntaxerror22's code. I made a folder in "UDK/Developement/src" and called it "codingtest" and within that folder a "Classes" folder. I also edited the defaultengine.ini to recognize my new folder.
            Earlier I made a simple "note" actor to test out my knowlage and it worked fine.
            Anyways, I copied the first chunk of code and named the file "ActionPawn.uc" and the second "ActionPlayerController.uc". I then went into the defaultinput.ini and added a ";" infront of ".Bindings=(Name="MouseScrollUp",Command="GBA_Prev Weapon")" and ".Bindings=(Name="MouseScrollDown",Command="GBA_Ne xtWeapon")" and added the relevent code afterwords.

            So there I had it, a new folder with just the two classes and nothing else. The only things I changed were the defaultengine and defaultinput. Compiling had no warning or errors.
            I then changed my game type for PIE to gameinfo. However, when played the game it didn't seem to be working. It was just an empty first person view that could fly around the map.

            Trying to find a solution I procceded to try online|offworld's code. I replaced the code for "ActionPawn.uc", "ActionPlayerController.uc" and added the "MyGameInfo.uc". I then compiled and got 12 warnings! I'm not a programmer and I have no idea what they mean. I decided to try going forwards anyways. When I tried gameinfo I got the same first person flying. But when I tried mygameinfo, I get an error saying "could not spawn".

            There. A step by step explaination of everything I did. I literally did nothing else. Didn't touch the coding either.
            Could someone please tell me what is going wrong and/or help me through this? I desperately need this camera to work for my game.

            EDIT: I'm using notepad to do my coding. Would that be the cause? Should I go through the hassle of downloading a different program?



              Great code! But I wish that when the gun firing the projectiles follow the direction the character is pointing the gun regardless of where the camera is looking.

              Any ideas?


                Alright, I'm still trying to get this to work and could still use some help.

                I've been playing around and have managed to rid myself of all the warnings but 4. They problem was with lines 117, 118, 119, and 120 of ActionPawn.uc.
                These are the line of code if: "What to change if you'd like to use your own meshes and animations." Since I don't have my pawn model made yet I just commented the lines out. (I hope that the code still works like this.)

                The remaining 4 warnings talk about lines 5 and 6 of MyGameInfo.uc.

                The code is:

                (5) PlayerControllerClass=class'ioflow_rpg.ActionPlaye rController'
                (6) DefaultPawnClass=class'ioflow_rpg.ActionPawn'

                The warnings read:

                MyGameInfo (5) "Warning, ClassProperty Engine.GameInfo:PlayerControllerClass: unresolved reference to 'class' ioflow_rpg.ActionPlayerController"
                MyGameInfo (5) "Warning, Invalid property value in defaults: PlayerControllerClass=class 'ioflow_rpg.ActionPlayerController'
                MyGameInfo (6) "Warning, ClassProperty Engine.GameInfo:DefaultPawnClass: unresolved reference to 'class' ioflow_rpg.ActionPawn"
                MyGameInfo (6) "Warning, Invalid property value in defaults: DefaultPawnClass=class 'ioflow_rpg.ActionPawn'
                I'm afraid I don't have enough coding knowledge to understand why I'm getting these unresolved references and invalid property values.
                Please if someone could help me out I would be forever grateful!!




                    Welp, came back to this page to update on the fact that I figured it out. I'll admit that despite my experience I should have seen it earlier. :|

                    Thank you so much for replying though VendorX! I really appriciate it.


                      nyc tutorial but i wana knw is there any way to make ur cam a little side way *** my chracter is in the middle of screen and i want him to a bit on left side like other 3rd person will i do that


                        Originally posted by HUxI View Post
                        nyc tutorial but i wana knw is there any way to make ur cam a little side way *** my chracter is in the middle of screen and i want him to a bit on left side like other 3rd person will i do that
                        You can do this by going into the skeletal mesh properties and then adjust the origin position like '-40' on the x or y's position ( so that he is not in the middle of the origin). Hope that helps


                          Originally posted by JmPrsh153 View Post
                          You can do this by going into the skeletal mesh properties and then adjust the origin position like '-40' on the x or y's position ( so that he is not in the middle of the origin). Hope that helps
                          yes it helps in wht i wana do but nw d problem is that whnever i press A and D to move the player move towards and away from camera respectivly.......what should i change in controller code so it wont happen and also i want to strafe right and left instead of player to face towards it and move


                            Hello guys. I read all the 17 pages and tried all the methods and I cant see the robot on screen. Something has to be working because I can adjust the zoom level using the mouse wheel.
                            This is my code

                            PHP Code:
                            class AnotherTestGameInfo extends GameInfo
                            PlayerControllerClass = class 'AnotherTest.AnotherTestActionPlayerController' //Setting the Player Controller to your custom script
                            DefaultPawnClass = class 'AnotherTest.AnotherTestActionPawn' //Setting the Pawn to your custom script

                            PHP Code:
                            class AnotherTestActionPawn extends UTPawn;

                            float CamOffsetDistance//distance to offset the camera from the player in unreal units 
                            var float CamMinDistanceCamMaxDistance
                            float CamZoomTick//how far to zoom in/out per command 
                            var float CamHeight//how high cam is relative to pawn pelvis 

                            //override to make player mesh visible by default 
                            simulated event BecomeViewTargetPlayerController PC 

                            local UTPlayerController UTPC


                               if (
                            LocalPlayer(PC.Player) != None
                            UTPC UTPlayerController(PC); 
                                  if (
                            UTPC != None
                            //set player controller to behind view and make mesh visible 
                            //Show Crosshair = false, hide = true 
                            UTPC.bNoCrosshair false

                            //orbit cam, follows player controller rotation 
                            simulated function bool CalcCamerafloat fDeltaTimeout vector out_CamLocout rotator out_CamRotout float out_FOV 

                            local vector HitLoc,HitNormEndStartvecCamHeight

                            vecCamHeight vect(-20,20,0); 
                            Start Location
                            End = (Location+vecCamHeight)-(Vector(Controller.Rotation) * CamOffsetDistance);  //cam follow behind player controller 
                            out_CamLoc End

                            //trace to check if cam running into wall/floor 
                            out_CamLoc HitLoc vecCamHeight


                            simulated function CamZoomIn() 

                            CamOffsetDistance CamMinDistance)        CamOffsetDistance-=CamZoomTick

                            simulated function CamZoomOut() 

                            CamOffsetDistance CamMaxDistance)     CamOffsetDistance+=CamZoomTick


                            CamHeight 50.0 

                            PHP Code:
                            class AnotherTestActionPlayerController extends UTPlayerController;

                            //Update player rotation when walking 
                            state PlayerWalking 

                            ignores SeePlayerHearNoiseBump

                            ProcessMove(float DeltaTimevector NewAcceleDoubleClickDir DoubleClickMoverotator DeltaRot
                            local Vector tempAccel
                            local Rotator CameraRotationYawOnly

                            Pawn == None 

                                  if (
                            Role == ROLE_Authority
                            // Update ViewPitch for remote clients 
                            Pawn.SetRemoteViewPitchRotation.Pitch ); 

                            tempAccel.=  PlayerInput.aStrafe DeltaTime 100 PlayerInput.MoveForwardSpeed
                            tempAccel.PlayerInput.aForward DeltaTime 100 PlayerInput.MoveForwardSpeed
                            tempAccel.0//no vertical movement for now, may be needed by ladders later 
                                 //get the controller yaw to transform our movement-accelerations by 
                            CameraRotationYawOnly.Yaw Rotation.Yaw;  
                            tempAccel tempAccel>>CameraRotationYawOnly//transform the input by the camera World orientation so that it's in World frame 
                            Pawn.Acceleration tempAccel
                            Pawn.FaceRotation(Rotation,DeltaTime); //notify pawn of rotation 


                            //Controller rotates with turning input 
                            function UpdateRotationfloat DeltaTime 

                            local Rotator   DeltaRotnewRotationViewRotation

                            ViewRotation Rotation
                               if (

                            // Calculate Delta to be applied on ViewRotation 
                            DeltaRot.Yaw   PlayerInput.aTurn
                            DeltaRot.Pitch   PlayerInput.aLookUp

                            ProcessViewRotationDeltaTimeViewRotationDeltaRot ); 

                            NewRotation ViewRotation
                            NewRotation.Roll Rotation.Roll

                               if ( 
                            Pawn != None 
                            Pawn.FaceRotation(NewRotationdeltatime); //notify pawn of rotation 

                            exec function NextWeapon()  


                            exec function PrevWeapon()  




                            Is this the correct way to load the game info?(pic)




                              I'm asking here because I used that type of camera. I'd like to control the camera rotation (left and right) with the left stick on the Xbox 360 controller.
                              But I don't know where I can change that, I don't find it int the DefaultInput.ini nor in the camera code. Maybe i'm missing it

                              Thanks for any help !

                              And thanks for the code, it works great


                                How do you slightly move the camera to the right of the player to give a third person shooter kinda look? I tried many possibilities but the rotation was messed up though the offset was in proper place