LERNGASM.com

icon_user_100.png

First, right click in the content browser and add a new blueprint pawn class and then open the blueprint.

You can add each individual part manually or just copy and paste this “code” below the picture once you have your pawn outliner selected (click on “default scene root” then ctrl +v).

Basic hierarchy

  • static mesh (for collision)
    • static mesh (character mesh)
    • spring arm
      • camera

Basic Pawn code

				
					Begin Object Class=/Script/Engine.StaticMeshComponent Name="StaticMeshComponent_322" ExportPath="/Script/Engine.StaticMeshComponent'/Engine/Transient.StaticMeshComponent_322'"
   StaticMesh="/Script/Engine.StaticMesh'/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube'"
   BodyInstance=(ObjectType=ECC_PhysicsBody,bLockXRotation=True,bLockYRotation=True,CollisionProfileName="PhysicsActor",bSimulatePhysics=True)
   bVisible=False
End Object
Begin Object Class=/Script/Engine.SpringArmComponent Name="SpringArmComponent_15" ExportPath="/Script/Engine.SpringArmComponent'/Engine/Transient.SpringArmComponent_15'"
   TargetArmLength=500.000000
   SocketOffset=(X=0.000000,Y=0.000000,Z=100.000000)
   RelativeLocation=(X=0.000000,Y=0.000000,Z=54.072358)
End Object
Begin Object Class=/Script/Engine.CameraComponent Name="CameraComponent_14" ExportPath="/Script/Engine.CameraComponent'/Engine/Transient.CameraComponent_14'"
   bUsePawnControlRotation=True
End Object
Begin Object Class=/Script/Engine.StaticMeshComponent Name="StaticMeshComponent_323" ExportPath="/Script/Engine.StaticMeshComponent'/Engine/Transient.StaticMeshComponent_323'"
   StaticMesh="/Script/Engine.StaticMesh'/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere'"
   RelativeRotation=(Pitch=0.000000,Yaw=-89.999999,Roll=0.000000)
End Object

				
			

On your base collision mesh properties, enable physics, and lock x and y rotations.  (you only need z because that allows it to spin like a top but prevents other wobble directions)

Also make sure your collision preset is set to “physics actor” if it is not automatically. 

Then make a new gamemode.  Blueprint> blueprint class search for gamemodebase

Open game mode blueprint and select your new pawn in the default pawn option.

Open world settings by clicking the settings cog on the top right and now select your new game mode as default game mode

 

Adding Movement

Jumping

Add these nodes to your character pawn actor now and you should be able to at least jump.  Make sure to set your jump speed in the z value on the last node.

You can copy and paste the code below instead of doing it manually, just replace the root collision node with your collision object.

Jump Code

				
					Begin Object Class=/Script/BlueprintGraph.K2Node_InputKey Name="K2Node_InputKey_0" ExportPath="/Script/BlueprintGraph.K2Node_InputKey'/Game/blueprints/pawn_char0.pawn_char0:EventGraph.K2Node_InputKey_0'"
   InputKey=SpaceBar
   NodePosX=304
   NodePosY=256
   NodeGuid=9854DC1C43F4888572FB4493E5789F7F
   CustomProperties Pin (PinId=4441ADD24741C31319AAB1864264908F,PinName="Pressed",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_0 51DF9B174E15097A7AC1F19A35D88F42,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=D19C028C400731F0BACE80ADB5B08F60,PinName="Released",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=A820C5BC47410A571FA9A8B5B5E3EDED,PinName="Key",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/InputCore.Key'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="None",AutogeneratedDefaultValue="None",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_0" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Game/blueprints/pawn_char0.pawn_char0:EventGraph.K2Node_CallFunction_0'"
   FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.PrimitiveComponent'",MemberName="SetPhysicsLinearVelocity")
   NodePosX=752
   NodePosY=256
   NodeGuid=45E50DDF4EEFD1EE288E4E87F08DC2C0
   CustomProperties Pin (PinId=51DF9B174E15097A7AC1F19A35D88F42,PinName="execute",PinToolTip="\nExec",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_InputKey_0 4441ADD24741C31319AAB1864264908F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=2E12154C40718CC1F1B6A7ABDE69EF0C,PinName="then",PinToolTip="\nExec",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=8ECCBEB8491598DE73925E92BC41F690,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nPrimitive Component Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.PrimitiveComponent'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_VariableGet_1 F20B6678465F515C05BCC9BC5DA61A35,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=8812C6D842626EB285703FB717314E4E,PinName="NewVel",PinToolTip="New Vel\nVector\n\nNew linear velocity to apply to physics.",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Vector'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.000000,0.000000,500.000000",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=950DCF4740D4AD5B5D7ED1B940E2E4A9,PinName="bAddToCurrent",PinToolTip="Add to Current\nBoolean\n\nIf true, NewVel is added to the existing velocity of the body.",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="false",AutogeneratedDefaultValue="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=8A932D364D2AE4FECA54CAAFA8E64C4C,PinName="BoneName",PinToolTip="Bone Name\nName\n\nIf a SkeletalMeshComponent, name of body to modify velocity of. \'None\' indicates root body.",PinType.PinCategory="name",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="None",AutogeneratedDefaultValue="None",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_VariableGet Name="K2Node_VariableGet_1" ExportPath="/Script/BlueprintGraph.K2Node_VariableGet'/Game/blueprints/pawn_char0.pawn_char0:EventGraph.K2Node_VariableGet_1'"
   VariableReference=(MemberName="mesh_collision",bSelfContext=True)
   NodePosX=464
   NodePosY=400
   NodeGuid=83F09FC34CE6405985E6D0AA4BFDAF09
   CustomProperties Pin (PinId=F20B6678465F515C05BCC9BC5DA61A35,PinName="mesh_collision",Direction="EGPD_Output",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.StaticMeshComponent'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_0 8ECCBEB8491598DE73925E92BC41F690,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=69F4DA8A4A8C991EE87218B99BC1F352,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/Engine.BlueprintGeneratedClass'/Game/blueprints/pawn_char0.pawn_char0_C'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
				
			

Forward / Backward movement

Right click add input > input action.

Name it ia_move.  Change value type to axis2D (vector 2D).

Next, add an input>input mapping context.  Click plus button on mappings to add a new slot and select ia_move.

Click keyboard button and press key w, s, a, or d, and then do the same thing for the other 3 keys.

// W  [forward]

Add modifier on W key.  Choose “swizzle input axis values.”  Make sure “order” is set to YXZ.

// S [backwards]

Add a modifier on S with “swizzle input axis values” also.  Add another modifier and choose “negate.”

// D [right]

For D you dont need to add anything.

// A [left]

For A add a “negate” modifier (no swizzle)

 

In character blueprint add “cast to player controller” after event begin play.  For object use “get controller” node.

for as player controller, use “get enhanced input local player subsystem.”  Add ” ? is valid” node.

 

From enhanced input node, add a “add mapping context” node.  Also connect this to is valid node.  Chose mapping context you made in the dropdown.

Leave a Reply

Your email address will not be published. Required fields are marked *