Creating a new Pawn

Almost there! Now we need to create our actual character. This is perhaps the most fun part, as it is probably the easiest to implement and understand. Begin by creating a new text document and naming it “MyPawn.uc”. Within that document, paste the following code:

[code]
Class MyPawn extends GamePawn;

simulated event PostBeginPlay()
{
super.PostBeginPlay();
`Log("Custom Pawn up");
}

simulated function name GetDefaultCameraMode( PlayerController RequestedBy )
{
`Log("Requested SideScrolling");
return ‘SideScrolling’;
}

defaultproperties
{
Components.Remove(Sprite)
//MOVEMENT COMPONENTS//
GroundSpeed=400.0
JumpZ=800.0

Begin Object Name=MyLightEnvironment
ModShadowFadeoutTime=0.25
MinTimeBetweenFullUpdates=0.2
AmbientGlow=(R=.01,G=.01,B=.01,A=1)
AmbientShadowColor=(R=0.15,G=0.15,B=0.15)
LightShadowMode=LightShadow_ModulateBetter
ShadowFilterQuality=SFQ_High
bSynthesizeSHLight=TRUE
End Object
Components.Add(MyLightEnvironment)

Begin Object Name=InitialSkeletalMesh
CastShadow=true
bCastDynamicShadow=true
bOwnerNoSee=false
LightEnvironment=MyLightEnvironment;
BlockRigidBody=true;
CollideActors=true;
BlockZeroExtent=true;
PhysicsAsset=PhysicsAsset’CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics’
AnimSets(0)=AnimSet’CH_AnimHuman.Anims.K_AnimHuman_AimOffset’
AnimSets(1)=AnimSet’CH_AnimHuman.Anims.K_AnimHuman_BaseMale’
AnimTreeTemplate=AnimTree’CH_AnimHuman_Tree.AT_CH_Human’
SkeletalMesh=SkeletalMesh’CH_LIAM_Cathode.Mesh.SK_CH_LIAM_Cathode’
End Object

Begin Object Name=CollisionCylinder
CollisionRadius=+0021.000000
CollisionHeight=+0044.000000
End Object
CylinderComponent=CollisionCylinder

Mesh=InitialSkeletalMesh;
Components.Add(InitialSkeletalMesh);
}
[/code]

Breaking down the code

Since we want to tweak some of the values to make the pawn act more like Mega Man, therefore we adjust the added this code:

[code]
GroundSpeed=400.0
JumpZ=800.0
[/code]

This slows our character down a bit, as well as increases the jumping height. Now that Mega Man has an increased jumping height we need to increase his weight, or gravity, so that he doesn’t appear to be floating. I haven’t had time to adjust that just yet, but when I do I will update the tutorial.

Something funny happens when you edit this pawn as well: the collision cylinder on the Z axis is off for some reason, therefore we need to move it higher. You’ll notice if you remove this code from the class, that your character seems to be floating a few feet above the geometry. Therefore, we insert this code to offset that:

[code]

Begin Object Name=CollisionCylinder
CollisionRadius=+0021.000000
CollisionHeight=+0044.000000
[/code]

Changing the SkeletalMesh

Not satisfied with the skin or mesh that you have on your character? The code below is what determines which mesh will appear. Just swap out the ‘CH_LIAM_Cathode.Mesh.SK_CH_LIAM_Cathode’ with another one in your package, and you’ll be good to go! Same goes for animations and physics applied to the pawn.

[code]

physicsAsset=PhysicsAsset’CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics’
AnimSets(0)=AnimSet’CH_AnimHuman.Anims.K_AnimHuman_AimOffset’
AnimSets(1)=AnimSet’CH_AnimHuman.Anims.K_AnimHuman_BaseMale’
AnimTreeTemplate=AnimTree’CH_AnimHuman_Tree.AT_CH_Human’
SkeletalMesh=SkeletalMesh’CH_LIAM_Cathode.Mesh.SK_CH_LIAM_Cathode'</pre>
[/code]

7 thoughts on “Creating a new Pawn

    • Sorry for the delay, WordPress didn’t notify me sooner that someone had left a message here!

      No, I haven’t played with this code in quite some time, and have since moved on to other projects, so I’ve never corrected that. Sorry :/

  1. Man, that was one excellent read. Do you write your own content
    or do you outsource it? I outsource the information on my website and by the
    looks of this website, I might need to outsource some of it to you, lol!

    • I write all of this myself. It’s all quite a bit old at this point, but I wrote an UnrealScript Programming book last fall, so all of my code in there is brand new.

  2. It’s exhilarating to find in-depth info that is not autospun garbage on the first Two pages of google. Nearly all useful websites are 5 and 6 pages back in google these days, happy to see one has broken away from the pack.

Leave a Reply