Making A Playable Character
Making A Playable Character
Game Mode
Add blueprint class, Game Mode Base
Name it MyGameMode
Make it the default mode
Character
Add blueprint class, Character
Name it MyCharacter
Add Camera, Location 20, 0, 60
Turn on Use Pawn Control Rotation
Select Character Movement component, Change Air Control to 0.5
Player Controller
Add blueprint class, Player Controller
Name it MyPlayerController
Open MyGameMode, Default Pawn Class to MyCharacter and Player Controller Class
to MyPlayer Controller
Input Actions
Add Input Action
Name it IA_Jump
Make 2 more (IA_Look and IA_Move)
Change Value Types, IA_Jump (Digital), IA_Look (Axis 2D), IA_Move (Axis-2D)
Mapping Context
Add Input Mapping Context
Name it IMC_Default
Add Input, Map IA_Jump to Spacebar and Gamepad Face Button Bottom
Make Player Controller Use This Input Mapping Context
Open MyCharacter (Character Blueprint)
Get Player Controller node
Return value to Get Enhanced Local Player Subsystem to Add Mapping Context node
Change Mapping Context pin to IMC-Default
Event Begin Play to Add Mapping Context
Script Jumping Logic
Open MyPlayerController
Get Player Character node to Cast to MyCharacter object pin
Event Begin Play to Cast to MyCharacter
Promote As My Character pin to variable, Name it MyCharacter
(Move to new part of the Event Graph)
Enhanced Input Action Event node IA_Jump
Add a get node for MyCharacter variable
Connect get node to a Jump function node target pin
Connect triggered pin of IA_Jump to Jump node
Script Look Logic
Open MyPlayerController
Enhanced Input Action Event node IA_Look
Connect get node of MyCharacter variable to Add Controller Yaw Input node
Triggered to Yaw Input
Split Struct pin of Action Value (Right click pin)
X to Val (Yaw Input)
Connect MyCharacter variable (again) to a Add Controller Pitch Input node
Y to Val (Pitch Input node)
Connect Yaw and Pitch inputs together
Add Modifiers
Open IMC_Default (Input Mapping Context)
Add negate modifier to IA_Look, Only for Y (Mouse Action Map)
Add deadzone modifier to IA_Look (Gamepad Action Map)
Script Movement Logic
Open IMC_Default
Map IA_Move to W,A,S,D keys + Gamepad Left Thumbstick 2D Axis
Add modifiers W(Swizzle), A(Negate), S(Swizzle+Negate), Gamepad(Deadzone)
Open MyPlayerController, Add another MyCharacter get node
Add an Enhanced Input Action Event IA_Move node
My Character node to a Add Movement Input
Triggered to Add Movement Input Execution pin
My Character node to a Get Actor Right Vector Function to World Direction
Split Struct pin of Action Value pin, X to Scale Value of Add Movement Input
MyCharacter node to a new Add Movement Input node
My Character node to a Get Actor Forward Vector node, return value to World
Direction
Y to Scale Value
Connect both Add Movement Input nodes