Jump to content

UDK Need to change the camera location to first person through code.

TEDWARDS

So I need to change the camera to first person, I am using the UDK MOBA starter kit and am a complete noob when it comes to code. It would be great if someone could help me :D  I have pasted the code in here and appreciate any help given.

 //=============================================================================// UDKMOBACamera_PC//// Camera class which handles the camera position. The camera has two modes// depending on the platform that the game is running on. The camera uses a // interpolating method; so that movement of the camera is always fluid.//// On PC it uses a fixed height birds eye view. The player is able to move// the camera by using the arrow keys and when the mouse is on the edge of the // screen. The player can also go straight back to their hero by using a // console command, and lock onto their hero by double tapping the console// command. // // Copyright 1998-2012 Epic Games, Inc. All Rights Reserved.//=============================================================================class UDKMOBACamera_PC extends UDKMOBACamera; // Camera propertiesvar const UDKMOBACameraProperties_PC CameraProperties; /** * Query ViewTarget and outputs Point Of View. * * @param OutVT ViewTarget to use. * @param DeltaTime Delta Time since last camera update (in seconds). * @network Client */function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime){local UDKMOBAPlayerController UDKMOBAPlayerController;local Vector CameraDirectionX, CameraDirectionY, CameraDirectionZ, CameraMoveDirection, CameraIntersectionPoint;local LocalPlayer LocalPlayer;local Vector2D MousePosition; // Return the default update camera targetif (CameraProperties == None){Super.UpdateViewTarget(OutVT, DeltaTime);return;} if (PCOwner != None){// Grab the mouse coordinates and check if they are on the egde of the screenif (PCOwner.MyHUD != None){LocalPlayer = LocalPlayer(PCOwner.Player);if (LocalPlayer != None && LocalPlayer.ViewportClient != None){MousePosition = LocalPlayer.ViewportClient.GetMousePosition();// Leftif (MousePosition.X >= 0 && MousePosition.X < 8){CameraMoveDirection.X = -1.f;}// Rightelse if (MousePosition.X > PCOwner.MyHUD.SizeX - 8 && MousePosition.X <= PCOwner.MyHUD.SizeX){CameraMoveDirection.X = 1.f;}else{CameraMoveDirection.X = 0.f;} // Topif (MousePosition.Y >= 0 && MousePosition.Y < 8){CameraMoveDirection.Y = -1.f;}// Bottomelse if (MousePosition.Y > PCOwner.MyHUD.SizeY - 8 && MousePosition.Y <= PCOwner.MyHUD.SizeY){CameraMoveDirection.Y = 1.f;}else{CameraMoveDirection.Y = 0.f;}}} // Normalize the camera move direction based on the player inputCameraMoveDirection.X += PCOwner.PlayerInput.RawJoyRight;CameraMoveDirection.Y += (PCOwner.PlayerInput.RawJoyUp * -1.f);CameraMoveDirection = Normal(CameraMoveDirection); // Turn off hero tracking as soon as the player attempts to adjust the cameraif (!IsZero(CameraMoveDirection) && IsTrackingHeroPawn){IsTrackingHeroPawn = false;} if (IsTrackingHeroPawn){UDKMOBAPlayerController = UDKMOBAPlayerController(PCOwner);if (UDKMOBAPlayerController != None && UDKMOBAPlayerController.HeroPawn != None){DesiredCameraLocation = UDKMOBAPlayerController.HeroPawn.Location;}}else{// Grab the camera rotation axesGetAxes(CameraProperties.Rotation, CameraDirectionX, CameraDirectionY, CameraDirectionZ); DesiredCameraLocation += Vector(Rotator(CameraDirectionY) + Rot(0, 16384, 0)) * CameraMoveDirection.Y * PCOwner.PlayerInput.MoveForwardSpeed * DeltaTime;DesiredCameraLocation += CameraDirectionY * CameraMoveDirection.X * PCOwner.PlayerInput.MoveStrafeSpeed * DeltaTime;} // Find the point on the camera movement plane where the camera should be. This ensures that the camera stays at a constant heightclass'UDKMOBAObject'.static.LinePlaneIntersection(DesiredCameraLocation, DesiredCameraLocation - Vector(CameraProperties.Rotation) * 16384.f, CameraProperties.MovementPlane, CameraProperties.MovementPlaneNormal, CameraIntersectionPoint); // Linearly interpolate to the desired camera locationOutVT.POV.Location = VLerp(OutVT.POV.Location, CameraIntersectionPoint, CameraProperties.BlendSpeed * DeltaTime);} // Set the camera rotationOutVT.POV.Rotation = CameraProperties.Rotation;} // Default properties blockdefaultproperties{CameraProperties=UDKMOBACameraProperties_PC'UDKMOBA_Game_Resources_PC.Properties.CameraProperties'}
Edited by alpenwasser
code tags :)

PC Specs:


CPU: i5 4670K  4.5 GHz  | CPU COOLER: H80i | GPU:EVGA GTX 780Ti  |  Motherboard: MSI Z87I   |  Case: Bitfenix Prodigy  |  RAM: 8GB Avexir Venom  |  HDD: Seagate 1TB , 60GB Agility 3  Monitor: 32" HD TV (LOL)   PSU: Corsair 750W

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×