I am trying to follow the FPS tutorial from the wiki ( A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums ) as a base for making a character move around. I’ve done things a little bit differently such as using a pawn instead of a character and changed a couple of names. Besides that, there’s no reason it shouldn’t work. Can anyone tell me where I’ve gone wrong?
What happens based on the following code is I will press W or S and it will give me the 1 or -1 output on screen via the debug message, so obviously the controller exists and value is not 0.0, but there is no movement. The pawn is completely idle.
It appears that AddMovementInput isn’t doing anything.
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
class APlayerPawn : public APawn
virtual void BeginPlay() OVERRIDE;
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) OVERRIDE;
//Handles vertical movement
void MoveVertical(float Val);
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
APlayerPawn::APlayerPawn(const class FPostConstructInitializeProperties& PCIP)
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("WE ARE USING PLAYERPAWN"));
void APlayerPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
//Setup gameplay keybindings
InputComponent->BindAxis("MoveVertical", this, &APlayerPawn::MoveVertical);
InputComponent->BindAxis("Turn", this, &APlayerPawn::AddControllerYawInput);
void APlayerPawn::MoveVertical(float Value)
if ((Controller != NULL) && (Value != 0.0f))
// find out which way is forward
FRotator Rotation = Controller->GetControlRotation();
// add movement in that direction
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Blue, FString::FromInt((int)Value));
Because a Character is a special type of Pawn with built-in movement capabilities, it comes with a CharacterMovementComponent by default. The Pawn class can have a PawnMovementComponent, but if you didn’t add one when you created the Pawn, there isn’t one included by default. This means that the AddMovementComponent function has no PawnMovementComponent to work on, and is why you aren’t seeing your Pawn move forward or backward. For cases like this FPS tutorial, the built-in movement system and other controls of the Character class are a good starting point for your character, so that’s why we began with that base class.
Hope this helps with your question!
Can’t find anything in the documentation about adding one. How do I do it?
A lot of steps in the FPS tutorial actually rely on you using Character as the base class for your FPSCharacter, like setting up jumping and animations.
Pawn movement is often done with Set Actor Location. Some Blueprint examples of this are in the Blueprint Input Examples map of the Content Examples project, like BP_Pixel_Ship_Player.
If you do want to create specialized movement for your Pawn, you will first have to create a new class with PawnMovementComponent as its parent. You would then add this class as a component in your Pawn class. For examples of this, see the DefaultPawn and FloatingPawnMovement classes.
Thanks guys. Let me rephrase my entire question then.
I want to make a helicopter, I was using the FPS tutorial to see how you set up something inside of UE4 compared to Unity. I’ve only really used Unity before so this is all new to me. I think I used a bit too much of the example and naturally ran into problems.
Is a pawn the best way to go about this? Any tutorial that may help? Is UDK3 still relevant, just a different language, how much has changed?
Edit: Is there somewhere I can learn this stuff? Unfortunately there doesn’t seem to be many tutorials… (coz it’s new)
A good place to begin for C++ programming is probably the Programming Quick Start.
For general information about Pawns, Controllers, and other gameplay framework classes, check out the Gameplay Framework Quick Reference.
Hopefully, the FPS tutorial is a good starting point for you to get familiar with gameplay framework and C++ coding with Unreal Engine. We did use a Character in it instead of a basic Pawn, because of the built-in movement functions, but it should be a good overview of how things like the Game Mode, Characters, and input work together. Once you feel comfortable with that, you can take a look at creating your own helicopter class based on Pawn and setting up a HelicopterMovementComponent.
We’re definitely always working on improving the documentation, and this is an area we would like to add more information for, so keep checking in!
Thanks Lauren, for the information.
I’ve had a look through the documentation a few times but I’m still a little confused about a couple things:
Where can I find the information to go about creating a helicopter class based on a pawn? I’m really not sure where to begin.
Earlier you mentioned the DefaultPawn. I notice if I go into the source folder I can find the defaultpawn.h file but not the cpp files, I assume that’s what I’d need to use as an example or starting point?
Search the forums for 6DOF… I’m pretty sure someone posted a code example for how to create an UFO pawn.
I think this will give you a good start to get used to some important concepts and functions.
That’s all blueprints, and while a good resource, not quite what I’m after (want to use C++). That said - I will definitely try to replicate it because I’m sure the same concepts apply in one way or another.
Edit: My previous reply I asked where I can find things, and cpp was missing, obviously I just had to dl the source and there it is. So - disregard.
For the next release we want to include a template that shows how to create a simple flying non-Character Pawn in both C++ and BP.
I know this is an old topic, but I ran into this issue as well. Took way too long to figure it out.
If you have “GameState” set as the active Game State, then it does not work. You must set it to “GameStateBase”, or use a game state that inherits “GameStateBase”.
Perhaps the “GameState” object expects some authentication for multiplayer games.
It is easily reproduced by creating a new FPS C++ project, create a new Character in C++. Copy ALL the code from the template character the project provides to your new character. Update the game mode to use your new character and to use “GameState”. Test.