Results 1 to 35 of 35
  1. #1
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    56

    Default GoW Camera Tutorial extension

    Another gentlemen posted a great camera tutorial that would allow a zoom adjustable, Gears of War style camera. The only problem with it was it used some very low level classes as base classes. As most of you know, many people base their script off UTGame classes and UTGame uses CalcCamera() instead of a camera class. UTGame also implements bBehindView which initially is very similar but lacks the ability to zoom out etc. Below I've added the code necessary to create a zoomable 3rd person camera that has an aim implementation.


    Notes**
    All classes are prefaced in the following manner RE + Base class name. I.E (" REGameInfo")

    All values are easily adjusted both in default properties and at runtime for easy debugging/finding what you like.

    GameInfo - Main game type class
    Code:
    class REGameInfo extends UTGame;
    
    DefaultProperties
    {
    	DefaultPawnClass=class'REPawn'
    	HUDType=class'REHUD' //100% un-needed
    	PlayerControllerClass=class'REController'
    }

    Pawn - Where the magic happens
    Code:
    class REPawn extends UTPawn;
    
    var float CameraOffsetLength;
    
    var float GlobalCamZoom; /* Indexer value to allow camera memory of where the user last had his zoom set */
    
    /* The values that will actually be used in the camera calculation algorithm */
    var float CurrCamZoom; //The camera's position on the X axis or Forward/Backward
    var float CurrYZoom; //Camera's Left/Right position
    var float CurrFOV; // Camera's FOV used for a nice zoom effect
    var float CurrZ; // the camera's position on the Z axis or Up/Down
    /* Lerp values to allow smooth interpolation of the camera */
    var float TargetFOV;
    var float TargetCamZoom;
    var float TargetYZoom;
    var float TargetZ;
    
    /* Target values for where the camera should go when we shoulder/unshoulder the camera */
    var float ShoulderZoom;
    var float ShoulderYZoom;
    var float ShoulderFOV;
    var float ShoulderZ;
    var float NonShoulderZ;
    var float NonShoulderFOV;
    var float NonShoulderYZoom;
    /* Flag to indicate if the user zoomed in or not. */
    var bool bShoulderCam;
    
    var float CurrentCameraDistance, CurrentCameraOffsetLength;
    var Vector PawnEyeLocation;
    var Vector PlayerHitTarget;
    
    simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV)
    {
    	local vector CamStart, FirstHitLocation, HitLocation, HitNormal, CamDir, X, Y, Z, end;
    	local float DesiredCameraZOffset;
    	local bool bInsideHero, bObstructed;
    
    	local float DesiredCameraDistance;
    	local float CameraOffsetRatio;
    	local vector tempCamStart, tempCamEnd;
    	local Vector VectorX, VectorY, VectorZ;
    
    	local Actor CamTrace;
    
    	bObstructed = false;
    
    	//Mesh.SetOwnerNoSee(false);
    
    	// Handle the fixed camera
    	if (bFixedView)
    	{
    		out_CamLoc = FixedViewLoc;
    		out_CamRot = FixedViewRot;
    	}
    
    	if(bShoulderCam) // User has zoomed in, set our Lerp targets to where we're zooming to.
    	{
    		TargetYZoom = ShoulderYZoom;
    		TargetCamZoom = ShoulderZoom;
    		TargetFOV = ShoulderFOV;
    		TargetZ = ShoulderZ;
    	}
    	else // Default the Target, if the user was zoomed in, return the values back to normal otherwise do nothing
    	{
    		TargetYZoom = NonShoulderYZoom;
    		TargetCamZoom = GlobalCamZoom;
    		TargetFOV = NonShoulderFOV;
    		TargetZ = NonShoulderZ;
    	}
    
    	if(CurrZ != TargetZ) // Lerp the Z-Axis if the value changed
    	{
    		CurrZ = Lerp(CurrZ, TargetZ, 0.1);
    	}
    	if(CurrFOV != TargetFOV) // Lerp the FOV for the zoom effect
    	{
    		CurrFOV = Lerp(CurrFOV, TargetFOV, 0.1);
    		/* TODO: Change REController to the name of your PlayerController Class */
    		REController(Owner).SetFOV(CurrFOV); 
    	}
    	if(CurrCamZoom != TargetCamZoom) // Lerp the Zoom for a steady zoom in/out effect
    	{
    		CurrCamZoom = Lerp(CurrCamZoom, TargetCamZoom, 0.1);
    	}
    	
    	if(CurrYZoom != TargetYZoom) // Lerp the left/right movement of the camera when we zoom in to prevent model clipping
    	{
    		CurrYZoom = Lerp(CurrYZoom, TargetYZoom, 0.1);
    	}
    
    
    	ModifyRotForDebugFreeCam(out_CamRot);
    
    	CamStart = Location;
    	DesiredCameraZOffset = (Health > 0) ? GetCollisionRadius() * /*Default Value: 0.75*/ CurrZ : 0.f;
    	CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
    
    	CamStart.Z += CameraZOffset;
    	GetAxes(out_CamRot, X, Y, Z);
    
    	/*VectorX here you can implement camera zoom in/out or scaling or whatever you want to call it */
    	VectorX = X * GetCollisionRadius() * CurrCamZoom; //this vector determine depth of camera, how far from character it will be
    	VectorY = Y * GetCollisionRadius() * CurrYZoom; // this vector determine side of camera, negaive value pull character to left side, while positive to right side
    	VectorZ = (GetCollisionRadius() /* FMax(0,(1.0-CamRotZ.Z))*/ * Z) * -1.55; //this value try to pull camera forward while pitching down, and back while pitching up, but pulling back seems to dont work
    	CamDir = VectorX + VectorY + VectorZ;
    
    	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 (CamDir.Z <= GetCollisionHeight())
    	{
    		CamDir *= square(cos(out_CamRot.Pitch * 0.000000958738)); // 0.0000958738 = 2*PI/65536
    	}
    
    	out_CamLoc = CamStart - CamDir;
    
    	if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
    	{
    		out_CamLoc = HitLocation;
    		bObstructed = true;
    	}
    
    
    
    			/* This code is from ActionGam, thanks for fall, for creating this. 
    		 * It will determine back trace collision while closing to walls or sth like thaht*/
    		if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12),,TRACEFLAG_Blocking) != None)
    		{
        		DesiredCameraDistance = VSize(HitLocation-CamStart);
        		CurrentCameraDistance = (fDeltaTime < 0.5f) ? FClamp(DesiredCameraDistance * 2 * fDeltaTime + (1 - 2*fDeltaTime) * CurrentCameraDistance,0,DesiredCameraDistance) : DesiredCameraDistance;
    
        		HitLocation = CamStart + Normal(HitLocation-CamStart) * CurrentCameraDistance;
    
    			CameraOffsetRatio = CurrentCameraDistance/VSize(out_CamLoc - CamStart);
    			out_CamLoc = HitLocation;
    			bObstructed = true;
    		}
    
    		else
    		{
        		DesiredCameraDistance = VSize(out_CamLoc-CamStart);
        		CurrentCameraDistance = (fDeltaTime < 0.5f) ? FClamp(DesiredCameraDistance * 2 * fDeltaTime + (1 - 2*fDeltaTime) * CurrentCameraDistance,0,DesiredCameraDistance) : DesiredCameraDistance;
    
    			HitLocation = CamStart + Normal(out_CamLoc - CamStart) * CurrentCameraDistance;
    
    			CameraOffsetRatio = CurrentCameraDistance/VSize(out_CamLoc - CamStart);
    			out_CamLoc = HitLocation;
    		}
    
    		if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
    		{
    			out_CamLoc = HitLocation;
    			return false;
    		}
    		
    		/*Again thanks for fall, for this. It just inside character collision detection*/
    		tempCamStart = CamStart;
    		tempCamStart.Z = 0;
    		tempCamEnd = out_CamLoc;
    		tempCamEnd.Z = 0;
    
    		end = out_CamLoc + Normal(vector(out_CamRot))*32768; 
    		CamTrace = Trace(HitLocation, HitNormal, end, out_CamLoc, false);
    
    		PlayerHitTarget = HitLocation;
    
    		PawnEyeLocation = Location + EyeHeight * vect(0,0,1);
    
    		if(bObstructed && (VSize(tempCamEnd - tempCamStart) < CylinderComponent.CollisionRadius*1.25) && (out_CamLoc.Z<Location.Z+CylinderComponent.CollisionHeight) && (out_CamLoc.Z>Location.Z-CylinderComponent.CollisionHeight))
    		{
    			SetHidden(true);
    		}
    		else
    			SetHidden(false);
    
    		return !bObstructed;
    }
    
    
    
    DefaultProperties
    {
    	bShoulderCam = false;
    
    	/*TODO:  Modify camera zoom values to fit your tastes 
    	 * Be sure to set CurrCamZoom/TargetCamZoom to the GlobalCamZoom to prevent the 
    	 * camera from LERPing and giving a weird effect on game start */
    	CurrCamZoom = 5.0
    	TargetCamZoom = 5.0
    	GlobalCamZoom = 5.0
    	ShoulderZoom = 2.5
    
    	/*TODO: Modify Left/Right values to fit your tastes
    	 * Set Curr/Target values to your default values to avoid Lerping without change
    	 */
    	CurrYZoom=-0.5
    	TargetYZoom=-0.5
    	ShoulderYZoom=-1.0
    	NonShoulderYZoom=-0.5
    	/*TODO: Modify FOV values to fit your tastes
    	 * Set Curr/Target values to your default values to avoid Lerping without change
    	 */
    	CurrFOV=90.0
    	TargetFOV=90.0
    	ShoulderFOV=45.0
    	NonShoulderFOV=90.0
    	/*TODO: Modify Z values to fit your tastes
    	 * Set Curr/Target values to your default values to avoid Lerping without change
    	 */
    	CurrZ=0.75
    	TargetZ=0.75
    	ShoulderZ=0.50
    	NonShoulderZ=0.75
    
    
    }

    Player Controller - Allow us some interaction
    Code:
    class REController extends UTPlayerController;
    
    exec function NextWeapon()
    {
    	if(!REPawn(Pawn).bShoulderCam)
    		REPawn(Pawn).GlobalCamZoom += 1.0;
    }
    exec function PrevWeapon()
    {
    	if(!REPawn(Pawn).bShoulderCam)
    		REPawn(Pawn).GlobalCamZoom -= 1.0;
    }
    exec function ShoulderCam()//Set the camera into aim mode.  Decrease FOV and such
    {
    	REPawn(Pawn).bShoulderCam = true;
    }
    exec function ReturnCam() 
    {
    	REPawn(Pawn).bShoulderCam = false;
    }
    
    
    /**
     * Adjusts weapon aiming direction.
     * Gives controller a chance to modify the aiming of the pawn. For example aim error, auto aiming, adhesion, AI help...
     * Requested by weapon prior to firing.
    *
     * @param	W, weapon about to fire
     * @param	StartFireLoc, world location of weapon fire start trace, or projectile spawn loc.
     */
    
    //This function is required otherwise our aim will be off ever so slightly because we don't account for the camera offset in calculation.
    function Rotator GetAdjustedAimFor( Weapon W, vector StartFireLoc )
    {
    	local REPawn P;
    	local Rotator R;
    	local Vector V;
    	P = REPawn(Pawn);
    	// by default, return Rotation. This is the standard aim for controllers
    	// see implementation for PlayerController.
    	if ( Pawn != None )
    	{
    		// Gets the vector for our aim adjustment by taking the result of our HitLocation from running Trace() when our camera updates and subtracting from it our current location
    		V = P.PlayerHitTarget - P.PawnEyeLocation;
    
                    //Cast our Vector to a Rotator
    		R = Rotator(V);
    		
                    //Return our adjusted aim Rotator
    		return R;		
    	}
    	return Rotation;
    }
    
    DefaultProperties
    {
    	bBehindView=true //Required to route camera calculation to our portion of CalcCamera()
    }
    In UDKInput.ini, Find line 29. Find the LeftShift binding
    Code:
    Replace with this...
    Bindings=(Name="LeftShift",Command="ShoulderCam | OnRelease ReturnCam")

    OPTIONAL - Find line 142/RightMouseButton binding
    Code:
    Personally CoD and other random games have spoiled me with a RMB aim feature so this is why I added this little piece. 
    
    Replace with this...
    Bindings=(Name="RightMouseButton",Command="ShoulderCam | OnRelease ReturnCam")

  2. #2
    MSgt. Shooter Person
    Join Date
    Sep 2010
    Location
    Bolton, UK
    Posts
    46

    Default

    Perfect! Thank you so much Shozokui

  3. #3
    MSgt. Shooter Person
    Join Date
    Dec 2009
    Posts
    39

    Default

    can anyone tell me y this dont work when i play on pc it just plays with the default 1st person view any help b great

  4. #4
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Location
    England, Kent, Longfield, New Ash Green
    Posts
    356
    Gamer IDs

    Gamertag: Hitman Spitfire

    Default

    the camera works, but how do you make it so that the pawn turns with the camera once zoomed in?
    UDK Environmental Artist - for UnrealPHD
    Youtube channel for latest tests on UDK: http://www.youtube.com/user/jmprsh153?feature=mhee
    Online Portfolio: http://parishproductionmedia.moonfruit.com/

  5. #5
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    56

    Default

    Quote Originally Posted by colin2010 View Post
    can anyone tell me y this dont work when i play on pc it just plays with the default 1st person view any help b great
    The two reasons that come to mind are:

    1.) You're not using the proper game type.
    2.) You haven't initialized bBehindView to true in the default properties.

    Double check that your code is correct and setting bBehindView to true, then open the world properties in the editor and make sure default game for PIE is your game type.

  6. #6
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    56

    Default

    Quote Originally Posted by JmPrsh153 View Post
    the camera works, but how do you make it so that the pawn turns with the camera once zoomed in?
    Double check your code. The camera should not turn independently ever.

    The camera and pawn should rotate simultaneously.

  7. #7
    MSgt. Shooter Person
    Join Date
    Jul 2010
    Location
    England, Kent, Longfield, New Ash Green
    Posts
    356
    Gamer IDs

    Gamertag: Hitman Spitfire

    Default

    no sorry the camera does zoom in etc. as it should do but it doesnt like turn my pawn too.

    i want my pawn to always be facing forward etc.
    UDK Environmental Artist - for UnrealPHD
    Youtube channel for latest tests on UDK: http://www.youtube.com/user/jmprsh153?feature=mhee
    Online Portfolio: http://parishproductionmedia.moonfruit.com/

  8. #8
    Skaarj
    Join Date
    May 2010
    Posts
    2
    Gamer IDs

    Gamertag: Full Metaru

    Default

    Is there a way to force the character to walk/slow down while zoomed in, just like GoW? I mean, Left Shift doesn't even work, nor does "RightMouseButton",Command="ShoulderCam | Walking | OnRelease ReturnCam"
    Last edited by FullMetaru; 08-03-2011 at 05:08 PM.

  9. #9

    Default

    Hi
    This is great!!

    However, sometimes when i fire the "bullets" do not travel in the direction the character is facing, they go towards the box in the centre of the july build demo level (I think this may be the origin 0,0,0) any ideas??

    Has anybody else had this problem??

  10. #10
    Iron Guard
    Join Date
    Jun 2008
    Posts
    818
    Gamer IDs

    Gamertag: Black Fang666

    Default

    Edit: Nevermind. Good camera script.
    Last edited by skwisdemon666; 08-09-2011 at 12:43 AM.
    Want to collaborate? Want to chat UDK? Message me on Skype, Craig Delancy. Check out my UDK Youtube channel: http://www.youtube.com/user/xblBlack...ew=0&flow=grid

  11. #11
    MSgt. Shooter Person
    Join Date
    Jul 2006
    Location
    NC
    Posts
    94

    Default

    Quote Originally Posted by 3DG View Post
    However, sometimes when i fire the "bullets" do not travel in the direction the character is facing, they go towards the box in the centre of the july build demo level (I think this may be the origin 0,0,0) any ideas??

    Has anybody else had this problem??
    The problem is that PlayerHitTarget gets bad data if your crosshairs are aiming up at the sky, etc.

    To fix that problem, find this code near the end of CalcCamera( )...
    Code:
    CamTrace = Trace( HitLocation, HitNormal, end, out_CamLoc, false );
    
    PlayerHitTarget = HitLocation;
    and change it to this...
    Code:
    if( Trace( HitLocation, HitNormal, end, out_CamLoc, false ) != none )
    	PlayerHitTarget = HitLocation;
    else
    	PlayerHitTarget = end;
    The problem was that HitLocation has unreliable value if the Trace misses. You don't really need the CamTrace actor anyway, so just avoid it.
    "Blah!"
    -- Unknown

  12. #12
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    98

    Default

    Quote Originally Posted by Geist
    The problem is that PlayerHitTarget gets bad data if your crosshairs are aiming up at the sky, etc.

    To fix that problem, find this code near the end of CalcCamera( )...
    Code:

    CamTrace = Trace( HitLocation, HitNormal, end, out_CamLoc, false );

    PlayerHitTarget = HitLocation;

    and change it to this...
    Code:

    if( Trace( HitLocation, HitNormal, end, out_CamLoc, false ) != none )
    PlayerHitTarget = HitLocation;
    else
    PlayerHitTarget = end;

    The problem was that HitLocation has unreliable value if the Trace misses. You don't really need the CamTrace actor anyway, so just avoid it.
    Thanks.

    While runing the editor with the command line "-log" i can see some errors:

    Just after start the game in the editor (F8):


    After typing "quit" in the console:


    Tested it with one of the map templates of the "New map" dialog using Jully 2011 Beta.

  13. #13
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    137

    Default

    I confirm the errors above!

  14. #14
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    56

    Default

    My advice would be to read the errors better. They have script titles in there, but look at what they're trying to do.

    Partly it's trying to update the minimap in UTGame's GFxHUD. In template levels there is no minimap data to be sent, aka it accessed none.

    The other part is it's trying to set online status in online subsystems. Aka steam, etc.
    The "errors" you see aren't actual errors.

  15. #15
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    56

    Default

    Quote Originally Posted by Geist View Post
    The problem is that PlayerHitTarget gets bad data if your crosshairs are aiming up at the sky, etc.

    To fix that problem, find this code near the end of CalcCamera( )...
    Code:
    CamTrace = Trace( HitLocation, HitNormal, end, out_CamLoc, false );
    
    PlayerHitTarget = HitLocation;
    and change it to this...
    Code:
    if( Trace( HitLocation, HitNormal, end, out_CamLoc, false ) != none )
    	PlayerHitTarget = HitLocation;
    else
    	PlayerHitTarget = end;
    The problem was that HitLocation has unreliable value if the Trace misses. You don't really need the CamTrace actor anyway, so just avoid it.
    Thank you very much. I had missed that and was trying to pinpoint that problem.

  16. #16
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    It's not working for me is it because I have no camera class

  17. #17
    Marrow Fiend
    Join Date
    Jun 2009
    Posts
    4,479

    Default

    You don't need one.
    Please don't send me private messages asking how to use UDK unless it has to do with my work, everything I can teach is already out there.

    I am not support, I am here to learn myself.

  18. #18
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    R u sure does it work for u

  19. #19
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    56

    Default

    I can guarantee it works. I'm using a derivative of it in a professional project at the moment. UTGame does not use a camera class as it implements UTPawn in a different way than the standard Framework.

    Trying to find your problem can be tricky.

    If you copied the code exactly, the following comes to mind.

    1.) Error in configuration files. Double check DefaultEngine.ini to make sure you've included +EditPackage=<Insert your mod package name>

    2.) Not running the correct gametype. In the Editor go to View->World Properties->World Info->Default Gametype for Pie-><Insert your GameInfo class name>

    3.) You probably shouldn't be trying this as you have no prior knowledge of UScript, UDK and UE3 in general.

    I myself ended up just botching install after install of UDK until obtaining a firm grasp of the Configuration system before getting into code. It's probably the most essential part of the workflow process.

  20. #20
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Brazil
    Posts
    261

    Default

    Great tutorial!

    But I want know if is possible do a camera shake system in this code like in GOW3 when the character is sprinting.


    Thanks.

  21. #21
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    115

    Default

    I wrote this code. and I have this error:

    Code:
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(36) : Warning, 'FirstHitLocation' : unreferenced local variable
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(38) : Warning, 'bInsideHero' : unreferenced local variable
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(148) : Warning, 'CameraOffsetRatio' : unused local variable
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(177) : Warning, 'CamTrace' : unused local variable
    why?

    thanks

  22. #22
    Redeemer
    Join Date
    Jul 2011
    Location
    London, UK
    Posts
    1,748

    Default

    Quote Originally Posted by Confusion View Post
    I wrote this code. and I have this error:

    Code:
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(36) : Warning, 'FirstHitLocation' : unreferenced local variable
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(38) : Warning, 'bInsideHero' : unreferenced local variable
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(148) : Warning, 'CameraOffsetRatio' : unused local variable
    E:\=== game\UDK-2012-07_july\Development\Src\Western\Classes\====Pawn.uc(177) : Warning, 'CamTrace' : unused local variable
    why?

    thanks
    Those are just warnings and not errors, due to variables not being used or referenced.
    Also your pawn class, is it ====Pawn? if yes I would advise you to change it's name to a proper name, should you ever run into an issue, a class name should start with a letter or an underscore.

  23. #23
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    115

    Default

    Code:
    E:\game\UDK-2012-07_july\Development\Src\Western\Classes\WPawn.uc(36) : Warning, 'FirstHitLocation' : unreferenced local variable
    E:\game\UDK-2012-07_july\Development\Src\Western\Classes\WPawn.uc(38) : Warning, 'bInsideHero' : unreferenced local variable
    E:\game\UDK-2012-07_july\Development\Src\Western\Classes\WPawn.uc(148) : Warning, 'CameraOffsetRatio' : unused local variable
    E:\game\UDK-2012-07_july\Development\Src\Western\Classes\WPawn.uc(177) : Warning, 'CamTrace' : unused local variable

    how to fix this? (FirstHitLocation , bInsideHero, CameraOffsetRatio, CamTrace)

  24. #24
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    115

    Default

    I solved this problem ..
    but gun pulls elsewhere ...

    pics 1 ..
    http://s9.postimage.org/rbikrhjkv/image.jpg

    if you bullet hitting sky.. bullet goes to the middle map...

    pics 2..
    http://s16.postimage.org/edpu2luqt/image.jpg

  25. #25
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    115

    Default

    nobody knows?

  26. #26
    MSgt. Shooter Person
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    114

    Default

    This Is cool thanks for posting this.

  27. #27
    MSgt. Shooter Person
    Join Date
    Mar 2013
    Location
    Bridgwater, Somerset, United Kingdom
    Posts
    131

    Default

    I cant thank you enough dude, this is just what I needed a fix to the problem of not being able to use a gun in the tutorial

    http://forums.epicgames.com/threads/...ith-GOW-camera

    Your extension has solved this problem for me and just wanted to thank you I have referenced this extension in a comment on there tutorial to help out others. Oh and nice little touch with the cod style eye zoom much better than the alternate firing thanks.

    Works a treat

  28. #28
    MSgt. Shooter Person
    Join Date
    Mar 2013
    Location
    Bridgwater, Somerset, United Kingdom
    Posts
    131

    Default

    I only have one small error now and that is when I run my level from the batch file it starts in the basic fps mode its not picking up my game info code! hmmm any suggestions??

    Oh and I forgot to mention that yes I have used GameInfo in the editor and the config files
    Last edited by GunnerJnr; 03-26-2013 at 01:13 PM.

  29. #29
    MSgt. Shooter Person
    Join Date
    Mar 2013
    Location
    Bridgwater, Somerset, United Kingdom
    Posts
    131

    Default

    Quote Originally Posted by GunnerJnr View Post
    I only have one small error now and that is when I run my level from the batch file it starts in the basic fps mode its not picking up my game info code! hmmm any suggestions??

    Oh and I forgot to mention that yes I have used GameInfo in the editor and the config files
    Solved it just need to add this to GameInfo class for anybody else who has this trouble

    WOW took a while but i found the fix to get it running in the batch file. Just needed to add this to the GameInfo class.

    Code:
    static event class<GameInfo> SetGameType(string MapName, string Options, string Portal)
    {
    	return class'RhoneGame.RhoneGameInfo';
    }

  30. #30
    MSgt. Shooter Person
    Join Date
    Mar 2013
    Location
    Bridgwater, Somerset, United Kingdom
    Posts
    131

    Default

    Anyone know how to change the zoom so default camera is over shoulder and the zoom goes to first person style??

  31. #31

    Default

    Just Place the following code in your Pawn Class, it shoul
    Code:
    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;
    
       DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z : 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;
    }

  32. #32
    MSgt. Shooter Person
    Join Date
    Mar 2013
    Location
    Bridgwater, Somerset, United Kingdom
    Posts
    131

    Default ??

    Quote Originally Posted by HmoudMO View Post
    Just Place the following code in your Pawn Class, it shoul
    Code:
    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;
    
       DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z : 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;
    }
    I tried this but it didn't seem to work not sure if there has been a slight mix up somewhere! My Code is :

    Pawn Class:

    Code:
    class RhonePawn extends UTPawn
    	HideCategories(Movement, AI, Camera, Debug, Attachment, Physics, Advanced, Object);
    
    //makes player temporarily invulnerable to the enemy attacks so life depletes slower
    var bool bInvulnerable;
    var float InvulnerableTime;
    var bool bScoreDeaths;
    
    //sprint speed and stamina variables
    var float SprintSpeed;
    var float WalkSpeed;
    
    var float Stamina;
    var float SprintTimer;
    var float SprintRecoverTimer;
    var float Empty;
    var bool bSprinting;
    
    /** Used to decrease the poison length each tick */
    var int											 PoisonCountdown;
    
    /** Stores our flashlight */
    var RhoneWeaponFlashlight				 Flashlight;
    
    /** Used for flashing damage as pawn's HP drops */
    var float										 DamageOverlayTime;
    var	LinearColor						     DamageBodyMatColor;
    
    ///***************************************************************************
    //* Tells the pawn to draw all postrender functions
    //* http://forums.epicgames.com/archive/index.php/t-901388.html
    //***************************************************************************/
    //simulated function PostRenderFor(PlayerController PC, Canvas Canvas, vector CameraPosition,
    //vector CameraDir)
    //{
    //local vector ScreenPos;
    //
    //Super.PostRenderFor(PC, Canvas, CameraPosition, CameraDir);	
    //
    //ScreenPos = Canvas.Project(self.Location); 	
    ////canvas.setPos(200,200);
    //canvas.SetPos(ScreenPos.X,ScreenPos.Y +100);
    //canvas.DrawText("TEST POST RENDER!");
    //canvas.TextSize(Canvas.TextSize);
    //
    //}
    
    /***************************************************************************
    * Lets us know that the class is being called, for debugging purposes
    ***************************************************************************/
    simulated event PostBeginPlay()
    {
    	Super.PostBeginPlay();
    	`Log("================");
    	`Log("Rhone Pawn up");
    	/** Flashlight */ 
    	Flashlight = Spawn(class'RhoneWeaponFlashlight', self);			// Spawns the light on the player, setting self as owner
    
    	Flashlight.SetBase(self);								    // Sets the lights base on at the player	
    	Flashlight.LightComponent.SetEnabled(false);				// Light is off by default 
    	Flashlight.LightComponent.SetLightProperties(0.75);			// Starts at 75% brightness
    	FlashDmg();
    
    	/** called from UTPawn, spawns the default controller */
    	SpawnDefaultController();
    }
    
    /***************************************************************************
    * Called by RhoneWeapon_PoisonDamage when the pawn is shot
    ***************************************************************************/
    function PoisonPlayer()
    {
    	PoisonCountdown = 0;										// Reset Poison Counter
    	SetTimer(0.5, true, 'PoisonDmg');							// Every .5 seconds PoisonDmg() will be called
    }
    
    /***************************************************************************
    * NES style flashing damage timer to indicate how hurt a pawn is
    ***************************************************************************/
    function FlashDmgTimer()
    {
    
    	if (Health < HealthMax /2)
    	{
    		`log("HP is less than 50%");
    		SetTimer(2.2, true, 'FlashDmg');
    	}
    
    	if (Health < HealthMax /4)
    	{
    		`log("HP is less than 25%");
    		SetTimer(1.5, true, 'FlashDmg');
    	}	
    
    	if (Health < HealthMax /10)
    	{
    		`log("HP is less than 10%");
    		SetTimer(0.7, true, 'FlashDmg');
    	}	
    }
    
    /***************************************************************************
    * Sets the flashing overlay on the pawn to indicate damage taken
    ***************************************************************************/
    simulated function FlashDmg()
    {	
    	SetBodyMatColor(DamageBodyMatColor, DamageOverlayTime);		
    }
    
    /***************************************************************************
    * Called when a pawn is hit
    ***************************************************************************/
    function PlayHit(float Damage, Controller InstigatedBy, vector HitLocation, 
    class<DamageType> damageType, vector Momentum, TraceHitInfo HitInfo)
    {
    	Super.PlayHit(Damage, InstigatedBy, HitLocation, DamageType, Momentum, HitInfo);					
    	FlashDmgTimer();		
    }
    
    /***************************************************************************
    * Actually does the damage to the pawn
    ***************************************************************************/
    function PoisonDmg()
    {
    	Local Pawn P;
    
    	P = self;										// Set the pawn to yourself
    
    	/** Does 5 damage to the pawn of type UTDmgType_Burning */
    	TakeDamage( 5, None, Location, vect(0,0,0) , class'UTDmgType_Burning');
    	PoisonCountdown=PoisonCountdown+1;				// Increment timer
    	`Log("***Pawn Health:" @P.Health);				// Log for debugging
    
    	/** clear the infinitely looping 0.5 second timer after 10 counts of damage */
    	if(PoisonCountdown >= 10)
    	{
    		ClearTimer('PoisonDmg');
    	}
    }
    
    /***************************************************************************
    * Turns the light on and off
    ***************************************************************************/
    exec function ToggleFlashlight()
    {
    	if(!Flashlight.LightComponent.bEnabled)			// If the light is off...	
    	{
    		Flashlight.LightComponent.SetEnabled(true); // Then turn it on
    		`log("TOGGLE FLASHLIGHT ON");
    	}
    	else											// If it's already on
    	{
    		Flashlight.LightComponent.SetEnabled(false);// Turn it off
    		`log("TOGGLE FLASHLIGHT OFF");
    	}
    }
    
    /***************************************************************************
    * Forces the flashlight to use our pawn's rotation
    ***************************************************************************/
    event UpdateEyeHeight( float DeltaTime )
    {
    	Super.UpdateEyeHeight(DeltaTime);
    	Flashlight.SetRotation(Controller.Rotation);	// Flashlight will use our controller's rotation		
    
    	/**  Offset the light slightly, so that it looks as though it is coming from our pawn's eyes/helmet */
    	Flashlight.SetRelativeLocation(Controller.RelativeLocation + vect(20, 0, 25));
    }
    
    ///***********************************************************************************
    //**USED FOR TOP DOWN Camera**
    //* Forces the weapon to use the pawn's direction for aiming, and not the camera's
    //* shots will be fired in the direction the gun is pointed. Used by PlayerController
    //* Comment this out if you are not using any camera system other than top down. 
    //* @return POVRot.
    //***********************************************************************************/
    //simulated singular event Rotator GetBaseAimRotation()
    //{
    //local rotator POVRot, tempRot;
    //
    //tempRot = Rotation;
    //SetRotation(tempRot);
    //POVRot = Rotation;
    //
    //// Stops the player from being able to adjust the pitch of the shot, forcing the camera to always point
    //// down towards the pawn. We can still rotate left and right, however. 
    ////	POVRot.Pitch = 0;
    //
    //return POVRot;
    //}
    
    /***************************************************************************
    * Returns base Aim Rotation without any adjustment.  We simply use our rotation
    * Only use this if you want your weapon trace to follow where your gun is 
    * pointed. Projectiles will now follow your trace.  Comment out if you want
    *  to fire in middle of screen.
    * @return	POVRot
    ***************************************************************************/
    simulated singular event Rotator GetBaseAimRotation()
    {
    	local rotator	POVRot;
    
    	// We simply use our rotation
    	POVRot = Rotation;
    
    	// If our Pitch is 0, then use RemoveViewPitch
    	if( POVRot.Pitch == 0 )
    	{
    		POVRot.Pitch = RemoteViewPitch << 8;
    	}
    
    	return POVRot;
    }
    
    
    event Bump(Actor Other, PrimitiveComponent OtherComp, vector HitNormal)
    {
    	if(RhoneEnemy(Other) != none && !bInvulnerable)
    	{
    		bInvulnerable = true;
    		SetTimer(InvulnerableTime, false, 'EndInvulnerable');
    		TakeDamage(RhoneEnemy(Other).BumpDamage, none, Location, vect(0,0,0), class'UTDmgType_LinkPlasma');
    	}
    }
    
    function EndInvulnerable()
    {
    	bInvulnerable = false;
    }
    
    exec function startSprint()
    {
    	GroundSpeed = SprintSpeed;
    	bSprinting = true;
    	if(GroundSpeed == SprintSpeed)
    	{
    		StopFiring();
    		SetTimer(SprintTimer, false, 'EmptySprint');
    	}
    }
    
    exec function stopSprint()
    {
    	GroundSpeed = WalkSpeed;
    }
    
    simulated function EmptySprint()
    {
    	Stamina = Empty;
    	GroundSpeed = WalkSpeed;
    	bSprinting = true;
    	SetTimer(SprintRecoverTimer, false, 'ReplenishStamina');
    }
    
    simulated function ReplenishStamina()
    {
    	Stamina = 20.0;
    	bSprinting = false;
    }
    
    simulated function PlayFootStepSound(int FootDown)
    {
    	super.PlayFootStepSound(FootDown);
    }
    
    defaultproperties
    {
    	/** AI and navigation */
    	bAvoidLedges=true				// don't get too close to ledges
    		bStopAtLedges=true				// if bAvoidLedges and bStopAtLedges, Pawn doesn't try to walk along the edge at all
    		bUpdateEyeHeight=true			// Updates eye height so that the flashlight can become dynamic
    
    		/** Used for flashing damage as pawn's HP drops */
    		DamageOverlayTime=.1			// The flash lasts this long (float)
    		DamageBodyMatColor=(R=10)		// Sets the pawn to flash red (hence the R=10)
    
    		/** PostRender functions */
    		bPostRenderIfNotVisible = true	// IF true, may call PostRenderFor() even when this actor is not visible 
    		bPostRenderOtherTeam=true		// If true, call postrenderfor() even if on different team
    
    	//invulnerable 
    	bScoreDeaths=false
    		bCanPickupInventory=True
    		InvulnerableTime=0.6
    
    		//sprint and stamina settings
    		GroundSpeed=200.0
    		AirSpeed=200.0
    
    		WalkSpeed=220.0
    		SprintSpeed=500.0
    		SprintTimer=12.0
    		SprintRecoverTimer=8.0
    		Stamina=10.0
    		Empty=1
    }
    PlayerController Class:

    Code:
    class RhonePlayerController extends PlayerController;
    
    // Reference to the camera properties
    var const RhoneCameraProperties CameraProperties;
    
    /** Array used for setting the number of spawned companions */
    var Pawn						   Companions[3];
    
    var Actor CurrentPickup;
    
    /************************************************************************************
    * Rotator where the pawn will be aiming the weapon, forces the game to use the pawn's 
    * direction for aiming, not camera's
    ************************************************************************************/
    function Rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
    {
    	return Pawn.GetBaseAimRotation(); 
    }
    
    /************************************************************************************
    * Spawns companion pawns
    ************************************************************************************/
    function PlayerSpawned(NavigationPoint StartLocation)
    {
    	Companions[0] = Spawn(Class'RhonePawn',,, StartLocation.Location - vect(75,100,0), StartLocation.Rotation);
    	Companions[1] = Spawn(Class'RhonePawn',,, StartLocation.Location - vect(150,120,0), StartLocation.Rotation);
    	Companions[2] = Spawn(Class'RhonePawn',,, StartLocation.Location - vect(200,280,0), StartLocation.Rotation);
    }
    
    
    /*
    ================================================
    ValidPickup()
    
    Checks whether or not a certain actor is actually something we can pickup or not.
    Rather bad way to go about it, but since PickupFactories, DroppedPickups etc
    don't share and common parent class, aside from Actor, I'm unsure what to check for yet...
    ================================================
    */
    function bool ValidPickup(Actor Pickup)
    {
    	// all dropped pickups can be picked up, else they wouldn't exist
    	if (DroppedPickup(Pickup) != None)
    	{
    		return true;
    	}
    	else if (PickupFactory(Pickup) != None)
    	{
    		// If a pickup factory is hidden, it can't be picked up
    		return (PickupFactory(Pickup).bPickupHidden == false);
    	}
    	// If a pickup factory is hidden, it can't be picked up
    	else if (UTCarriedObject(Pickup) != None)
    	{
    		if (UTCarriedObject(Pickup).bHome == true)
    		{
    			return true;
    		}
    
    		if (UTCarriedObject(Pickup).IsInState('Dropped'))
    		{
    			return true;
    		}
    	}
    
    
    	// not a valid pickup
    	return false;
    }
    
    
    /*
    ================================================
    FindPickup()
    
    Finds a pickup (dropped, factory, weapon cache etc) within a limited radius.
    Returns true if its valid.
    ================================================
    */
    function bool FindPickup()
    {
    	local Actor Pickup, Best;
    	local vector ViewDir, PawnLoc2D, PickupLoc2D;
    	local float NewDot, BestDot;
    
    	if (Pawn == None)
    	{
    		return false;
    	}
    
    	CurrentPickup = None;
    
    	// are we standing on one?
    	if ((Pawn.Base != None) && ValidPickup(Pawn.Base))
    	{
    		CurrentPickup = Pawn.Base;
    		return true;
    	}
    
    	// Pick best nearby item
    	PawnLoc2D = Pawn.Location;
    	PawnLoc2D.Z = 0;
    	ViewDir = vector(Pawn.Rotation);
    
    	ForEach Pawn.OverlappingActors(class'Actor', Pickup, Pawn.VehicleCheckRadius)
    	{
    		if (ValidPickup(Pickup))
    		{
    			// Prefer items that Pawn is facing
    			PickupLoc2D = Pickup.Location;
    			PickupLoc2D.Z = 0;
    			NewDot = Normal(PickupLoc2D-PawnLoc2D) Dot ViewDir;
    			if ((Best == None) || (NewDot > BestDot))
    			{
    				// check that item is visible
    				if ( FastTrace(Pickup.Location,Pawn.Location) )
    				{
    					Best = Pickup;
    					BestDot = NewDot;
    				}
    			}
    		}
    	}
    
    	// remember what we found please
    	CurrentPickup = Best;
    
    	// if Best is not NULL, we found something
    	return (Best != None);
    }
    
    
    simulated function bool PerformedUseAction()
    {
    	Super.PerformedUseAction();
    
    	// If we find a valid pickup, touch it.
    	if (FindPickup())
    	{
    		CurrentPickup.Touch(Pawn, None, CurrentPickup.Location, Normal(CurrentPickup.Location-Pawn.Location));
    		pawn.bCanPickupInventory = true;
    		return true;
    	}
    
    }
    
    
    /*************************************************************************************************************
    * Place the name of the camera you want to use in here. If you want to adjust it on the fly within the editor, 
    * use the Archetype that we've created, so Class'RhoneGameCamera'. 
    * Otherwise, enter the name of the class you'd like to use. i.e. 'ThirdPersonCam'
    *************************************************************************************************************/
    defaultproperties
    {
    	//Switch between the different styles of camera
    	// Allows us to use the camera archetype within the editor to change values on the fly
    	//CameraClass = Class'ThirdPersonCam'//Telling the player controller to use your custom camera script
    	CameraClass = Class'OverShoulderCam'//Telling the player controller to use your custom camera script
    	//CameraClass = Class'FirstPersonCam'//Telling the player controller to use your custom camera script
    	//CameraClass = Class'TopDownCam'//Telling the player controller to use your custom camera script
    	//CameraClass = Class'SideScrollingCam'//Telling the player controller to use your custom camera script
    	CheatClass=class'DebugMenu'			// Reference for DebugMenu
    }
    Camera Class

    Code:
    class OverShoulderCam extends Camera;
    
    //Hardcoded vector offset we will use, rather than tweaking values in the editor's CameraProperties
    var const Vector OSCamOffset;
    //Hardcoded rotator offset we will use, rather than tweaking values in the editor's CameraProperties
    var const Rotator OSCamOffsetRotation;
    
    /**********************************************************************************
     * Query ViewTarget and outputs Point Of View.
     *
     * @param        OutVT            ViewTarget to use.
     * @param        DeltaTime        Delta Time since last camera update (in seconds)
     **********************************************************************************/
    function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
    {
        local Pawn Pawn;
        local Vector V, PotentialCameraLocation, HitLocation, HitNormal;
        local Actor HitActor;
    
        // UpdateViewTarget for the camera class we're extending from
        Super.UpdateViewTarget(OutVT, DeltaTime);
    
        // If there is an interpolation, don't update outgoing viewtarget 
        if (PendingViewTarget.Target != None && OutVT == ViewTarget && BlendParams.bLockOutgoing)
        {
            return;
        }
    
        Pawn = Pawn(OutVT.Target);
        if (Pawn != None)
        {
            // Hide the pawn's first-person weapon
            if(Pawn.Weapon != none)
    		{
                Pawn.Weapon.SetHidden(true);
    		}
    
            /************************************************************************************************
            * If you know the name of the bone socket you want to use, then replace 'WeaponPoint' with yours.
            * Otherwise, just use the Pawn's eye view point as your starting point
            *************************************************************************************************/
            //socket not found, use the other way of updating vectors
            if (Pawn.Mesh.GetSocketWorldLocationAndRotation('WeaponPoint', OutVT.POV.Location, OutVT.POV.Rotation) == false) 
            {
                //Start the camera location from the target eye view point
                OutVT.Target.GetActorEyesViewPoint(OutVT.POV.Location, OutVT.POV.Rotation);
            }
    
            // Force the camera to use the target's rotation
            OutVT.Target.GetActorEyesViewPoint(V, OutVT.POV.Rotation);
    
    		// Add the camera offset
    		OutVT.POV.Rotation += OSCamOffsetRotation;
    
            // Math for the potential camera location
            PotentialCameraLocation = OutVT.POV.Location + (OSCamOffset >> OutVT.POV.Rotation);        
    
            // Draw a trace to see if the potential camera location will work
            HitActor = Trace(HitLocation, HitNormal, PotentialCameraLocation, OutVT.POV.Location, true,,, TRACEFLAG_BULLET);
    
            // Will the trace hit world geometry? If so then use the hit location and offset it by the hit normal
            if (HitActor != None && HitActor.bWorldGeometry)
            {
                OutVT.POV.Location = HitLocation + HitNormal * 16.f;
            }
            else
            {
                OutVT.POV.Location = PotentialCameraLocation;
            }
        }
    }
    
    // Hardcoded vector & rotator values for our camera
    defaultproperties
    {
        OSCamOffset=(x=-60,y=20,z=25)
        OSCamOffsetRotation=(Pitch=-2048)
    }
    
    /********************
    *****Reference*******
    *********************
    * 65536 = 360 degrees
    * 32768 = 180 degrees
    * 16384 =  90 degrees
    *  8192 =  45 degrees
    *	182 =    1 degree
    *********************/
    and I am trying to implement a zoom from OverShoulderCam to A FPS style cam instead of third person to shoulder.

  33. #33

    Default

    A big thank you to Shozokui for posting this, it's exactly what I was looking for and the code works really well.

    However I have a problem, when the player (pawn) dies, the character mesh disappears upon re-spawn leaving just the weapon floating in mid-air. You can still move around and play but all you see is a gun floating in mid-air.

    Has anyone else encountered the same problem and more importantly does anyone have any suggestions on how to fix it?.

    Thanks in advance....

  34. #34

    Default

    Put this in your player controller class:

    Code:
    event Possess(Pawn inPawn, bool bVehicleTransition)
    {
    	Super.Possess(inPawn, bVehicleTransition);
    	SetBehindView(true);
    	// force garbage collection when possessing pawn, to avoid GC during gameplay
    	if ( bVehicleTransition )
    	{
    		if ( (WorldInfo.NetMode == NM_Client) || (WorldInfo.NetMode == NM_Standalone) )
    		{
    			WorldInfo.ForceGarbageCollection();
    		}
    	}
    }
    This is using the default "Possess" event for the player controller in my build. I just added a line. If you have any problems you need to find the Possess event that your player controller is using.

    This is the important part:

    SetBehindView(true);
    Last edited by Magnilucent; 04-18-2013 at 08:09 PM.

  35. #35

    Thumbs up

    Quote Originally Posted by Magnilucent View Post
    Put this in your player controller class:

    Code:
    event Possess(Pawn inPawn, bool bVehicleTransition)
    {
    	Super.Possess(inPawn, bVehicleTransition);
    	SetBehindView(true);
    	// force garbage collection when possessing pawn, to avoid GC during gameplay
    	if ( bVehicleTransition )
    	{
    		if ( (WorldInfo.NetMode == NM_Client) || (WorldInfo.NetMode == NM_Standalone) )
    		{
    			WorldInfo.ForceGarbageCollection();
    		}
    	}
    }
    This is using the default "Possess" event for the player controller in my build. I just added a line. If you have any problems you need to find the Possess event that your player controller is using.

    This is the important part:
    Fantastic! - problem solved, thanks for taking the time to post Magnilucent


 

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.