Here is the (NOT YET COMPLETE) code for the new DHPawn.uc
I am simply pushing in the code to get simple tasks done, then adding the obvious needs slowly.
This code just gets our model in and linked to our animset. Still needs an animtree, some sockets and some camera love.
You can see I'm already setting up the variables for that.
Code:
class DHPawn extends UDKPawn;
var vector Loc;
var rotator Rot;
var float ZoomAmount;
var name CameraStyle;
DefaultProperties
{
Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
bSynthesizeSHLight=TRUE
bIsCharacterLightEnvironment=TRUE
End Object
Components.Add(MyLightEnvironment)
Components.Remove(Sprite)
Begin Object Class=SkeletalMeshComponent Name=TotalSkeletalMesh
LightEnvironment=MyLightEnvironment
CastShadow=true
bCastDynamicShadow=true
bOwnerNoSee=false
BlockRigidBody=true
CollideActors=true
BlockZeroExtent=true
SkeletalMesh=SkeletalMesh'DHCharacters.Meshes.Sam_Pearly'
AnimSets(0)=AnimSet'DHCharacters.Meshes.Bip001'
Scale=1.6
BlockActors = true
BlockNonZeroExtent=true
//REMEMBER only scale the FIRST PARENT_ANIMcomponent (or else it multiplies)
End Object
Components.Add(TotalSkeletalMesh)
Mesh=TotalSkeletalMesh
CollisionType=COLLIDE_BlockAll
Begin Object Name=CollisionCylinder
CollisionRadius=+0020.000000
CollisionHeight=+36.000000
End Object
CylinderComponent=CollisionCylinder
Health=100 //100% Health
GroundSpeed=150.0 //Walking Speed is 75 (GroundSpeed is really Run Speed(Stupid UT3))
WalkingPct=2 //75 * 2 = 150 = Run Speed <-- This Swaps Run for Walk (Shift Key = Run)
bPushesRigidBodies=true
ZoomAmount = 96.0f
}
Now in order for all this to take effect when I play/build I add the DefaultGame.ini and DefaultEngine.ini (ADD AS LINK) to my project and change the following sections, I've commented out the parts I've replaced.
Changes and Additions to DefaultGame.ini
Code:
[URL]
MapExt=udk
AdditionalMapExt=mobile
;Map=UDKFrontEndMap.udk
;LocalMap=UDKFrontEndMap.udk
Map=TestCube.udk
LocalMap=TestCube.udk
TransitionMap=EnvyEntry.udk
EXEName=DHGame.exe
DebugEXEName=DEBUG-DHGame.exe
[UnrealEd.EditorEngine]
+EditPackages=UTGame
+EditPackages=UTGameContent
+EditPackages=DementiaHills
Changes and Additions to DefaultEngine.ini
Code:
[Engine.GameInfo]
;DefaultGame=UDKBase.SimpleGame
;DefaultServerGame=UDKBase.SimpleGame
;PlayerControllerClassName=UDKBase.SimplePC
DefaultGame=DementiaHills.DHGameInfo
DefaultServerGame=DementiaHills.DHGameInfo
PlayerControllerClassName=DementiaHills.DHPlayer
;------------------------------------------
So now if we hit Build/Debug in VS, it compiles and launches and our custom model is in UDK and attached to our basic controller. (I had to look down because my models scale is still off and I haven't moved the camera yet.)... But he doesnt animate and hes still pretty useless.
To make our custom camera (very simple version which I will add to later) we need 2 sockets for the way I do it.

Notice the sockets must be rotated or they will face the wrong way (up, to the side, etc)
I used Roll 90 and Yaw -90 that made it look straight ahead.
To make this work, I added two bits to the DHPawn.uc file:
Code:
simulated function name GetDefaultCameraMode( PlayerController RequestedBy ) {
return 'DH3P';
}
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
local vector Loc2, HitLocation, HitNormal;
local Actor HitActor;
switch( CameraStyle ) {
case 'DH3P': //Third Person, Camera Synced To Pawn (DEFAULT)
Mesh.GetSocketWorldLocationAndRotation('NoseBridge',Loc2,Rot,);
Mesh.GetSocketWorldLocationAndRotation('CamOrigin3P',Loc,Rot,);
Loc-= Vector(Rot) * (ZoomAmount); //Zoom back
out_CamRot=Rot; //Actually Set New Rotation
HitActor = Trace(HitLocation, HitNormal, Loc, Loc2, FALSE, vect(12,12,12));
out_CamLoc = (HitActor == None) ? Loc : HitLocation; //Actually Set New Location
break;
case 'DHFP': //First Person, Camera Synced To Pawn
Mesh.GetSocketWorldLocationAndRotation('NoseBridge',Loc,Rot,);
Loc-= Vector(Rot); //Zoom IGNORED
Loc2=Loc;
Loc2-= Vector(Rot) * (16); //Setup to Check Collisions
out_CamRot=Rot; //Actually Set New Rotation
HitActor = Trace(HitLocation, HitNormal, Loc, Loc2, FALSE, vect(12,12,12)); //On Collision Push Back into HEAD (not THROUGH WALLS)
out_CamLoc = (HitActor == None) ? Loc : HitLocation; //Actually Set New Location
break;
default:
`log("NO Cam Active! WTF IS WRONG WITH YOU?");
CameraStyle = 'DH3P';
break;
}
return true;
}
Works!!!

Here are the packages and map so far....
DHCharacters.upk
TestCube.udk
DementiaHills-CodeSample-No1.zip
Made with March 2012 UDK so I dont think they will load in anything earlier...
I will post more as soon as I regain consciousnesses....
Bookmarks