# First Person Shooter (Tutorial) - WASD problems

**URL:** <https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [March 30, 2014, 5:44pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435 "2014-03-30T17:44:17Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![clu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@clu](https://forums.unrealengine.com/u/clu)\
**Post date:** [March 30, 2014, 5:44pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/1 "2014-03-30T17:44:17Z")

</div>

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Great tutorial, but I am unable to receive/detect player WASD input after going through all the steps to the letter. Any help would be appreciated!

Details

1. created the all classes and editor settings as specified (all input mappings have been set up correctly as well)

2. debug print **will** show up for SetupPlayerInputComponent

3. debug prints **will not** show up for MoveForward/Moveright when keys are pressed, but the functions are definitely getting called every frame

```auto

void AFPSCharacter::MoveRight(float Value)
{

	//this will show up every frame when the game is run
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("MoveRight function called"));

	if ((Controller != NULL) && (Value != 0.0f))
	{
		//this never gets called when keyboard is pressed for some reason
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("MoveRight Input received"));
	
		//find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
		//Add movement in that direction
		AddMovementInput(Direction, Value);

	}

}

```

Worth noting that the tutorial section after WASD (mouse input) works fine (able to detect and use the mouse input)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bfee94af](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bfee94af](https://forums.unrealengine.com/u/anonymous_user_bfee94af)\
**Post date:** [March 30, 2014, 8:46pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/2 "2014-03-30T20:46:58Z")

</div>

> [@clu;9103](#):
>
> [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/First_Person_Shooter_%28Tutorial%29)
> 
> Great tutorial, but I am unable to receive/detect player WASD input after going through all the steps to the letter. Any help would be appreciated!
> 
> Details
> 
> 1. created the all classes and editor settings as specified (all input mappings have been set up correctly as well)
> 
> 2. debug print will show up for SetupPlayerInputComponent
> 
> 3. debug prints will not show up for MoveForward/Moveright when keys are pressed, but the functions are definitely getting called every frame
> 
> ```auto
> 
> void AFPSCharacter::MoveRight(float Value)
> {
> 
> //this will show up every frame when the game is run
> GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("MoveRight function called"));
> 
> if ((Controller != NULL) && (Value != 0.0f))
> {
> //this never gets called when keyboard is pressed for some reason
> GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("MoveRight Input received"));
> 	
> //find out which way is right
> const FRotator Rotation = Controller->GetControlRotation();
> const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
> //Add movement in that direction
> AddMovementInput(Direction, Value);
> 
> }
> 
> }
> 
> ```
> 
> Worth noting that the tutorial section after WASD (mouse input) works fine (able to detect and use the mouse input)

Hmm everything looks fine to me. Try this, I currently am using it in my game and it works.

```auto

	if ((Controller != NULL) && (Value != 0.0f))
	{
		FRotator Rotation = Controller->GetControlRotation();
		const FVector MoveDirection = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
		AddMovementInput(MoveDirection, Value);
	}

```

---

<div class="post-metadata">

**Author:** ![clu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@clu](https://forums.unrealengine.com/u/clu)\
**Post date:** [March 30, 2014, 10:01pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/3 "2014-03-30T22:01:59Z")

</div>

Thanks for the reply. The problem isn’t that particular code block, it’s that the block of code just never gets run. Anything after “if ((Controller != NULL) && (Value != 0.0f))” never gets hit at all, even though I am mashing on the wasd keys and all my bindings are correct in project settings (exactly like the tutorial screen below)

[![](https://d3ar1piqh1oeli.cloudfront.net/4/47/Input_wasd_settings_4.png/940px-Input_wasd_settings_4.png) ](https://d3ar1piqh1oeli.cloudfront.net/4/47/Input_wasd_settings_4.png/940px-Input_wasd_settings_4.png)

Here’s where the MoveRight and MoveForward functions are declared (in FPScharacter.h) in case it provides any clues. The functions get called every frame, I’m just not receiving wasd keyboard input (space bar works fine for jump though…strange stuff)

```auto

UCLASS() //this macro makes Unreal aware of your class, allowing it to perform optimizations, etc
class AFPSCharacter : public ACharacter //Class Declaration
{

	GENERATED_UCLASS_BODY() //macro that supplies automatic definitions

	//Declare a first person camera
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
		TSubobjectPtr<UCameraComponent> FirstPersonCameraComponent;

	//Declare a first person mesh visible only to player
	UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
		TSubobjectPtr<USkeletalMeshComponent> FirstPersonMesh;

	virtual void BeginPlay() OVERRIDE;	//declare the func and that it will override the BeginPlay() in the parent class, AActor

	protected:
		virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) OVERRIDE;

	UFUNCTION() //UFUNCTION makes engine aware function below it
	void MoveForward(float Val);	//handles moving forward/backward
	UFUNCTION()
	void MoveRight(float Val); //handles strafing
	UFUNCTION()
	void OnStartJump();				
	UFUNCTION()
	void OnStopJump();

};

```

---

<div class="post-metadata">

**Author:** ![Star\_Dust](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Star\_Dust](https://forums.unrealengine.com/u/Star_Dust)\
**Post date:** [March 30, 2014, 10:12pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/4 "2014-03-30T22:12:01Z")

</div>

I too am experiencing this problem, although slightly different. Right now I am up to the WASD part of the tutorial, and have not moved on. My bindings in the editor resemble that of the screenshot clu provided.

Similar to what clu posted, I placed on screen debug messages in the move forward, move right, and the SetupPlayerInputComponent functions (methods) and none are displaying.

The “Hello World” (FPSGameMode.cpp), and “We are using FPSCharacter!” (FPSCharacter.cpp) are both displaying correctly per the tutorial.

---

<div class="post-metadata">

**Author:** ![Star\_Dust](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Star\_Dust](https://forums.unrealengine.com/u/Star_Dust)\
**Post date:** [March 30, 2014, 10:25pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/5 "2014-03-30T22:25:15Z")

</div>

Sorry to double post, but maybe this will help chu.

In the template source code from GitHub the file “TP\_FirstPersonCharacter.cpp” functions (methods) do not have a check for Controller != Null

```auto

void ATP_FirstPersonCharacter::MoveForward(float Value)
{
	if (Value != 0.0f)
	{
		// find out which way is forward
		const FRotator Rotation = GetControlRotation();
		FRotator YawRotation(0, Rotation.Yaw, 0);

		// Get forward vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);

		// add movement in that direction
		AddMovementInput(Direction, Value);
	}
}

void ATP_FirstPersonCharacter::MoveRight(float Value)
{
	if (Value != 0.0f)
	{
		// find out which way is right
		const FRotator Rotation = GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// Get right vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);

		// add movement in that direction
		AddMovementInput(Direction, Value);
	}
}

```

---

<div class="post-metadata">

**Author:** ![Daerst](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daerst/32/266918_2.png) [@Daerst](https://forums.unrealengine.com/u/Daerst)\
**Post date:** [March 30, 2014, 10:28pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/6 "2014-03-30T22:28:30Z")

</div>

I suppose something is wrong with your BindAxis commands. Could you post them?

```auto

InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);

```

Check the spelling of your binding names. If they’re wrong, the functions won’t get called.

---

<div class="post-metadata">

**Author:** ![Star\_Dust](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Star\_Dust](https://forums.unrealengine.com/u/Star_Dust)\
**Post date:** [March 30, 2014, 10:33pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/7 "2014-03-30T22:33:01Z")

</div>

> [@Daerst;9244](#):
>
> I suppose something is wrong with your BindAxis commands. Could you post them?
> 
> ```auto
> 
> InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
> InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);
> 
> ```
> 
> Check the spelling of your binding names. If they’re wrong, the functions won’t get called.

Mine are:

```auto

void AFPSCharacter::SetupPlayerInputComponent(UInputComponent* InputComponent)
{
	
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("SetupPlayerInputComponent function called"));
	// set up gameplay key bindings
	InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
	InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);
}

```

Although as mentioned above I am not even getting the on screen message that the function is being called. All code in my project has been copy and pasted from the wiki and compiles without errors. I have verified that the inputs are named “MoveForward” & “MoveRight” in the editor - project - input section also.

---

<div class="post-metadata">

**Author:** ![clu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@clu](https://forums.unrealengine.com/u/clu)\
**Post date:** [March 30, 2014, 10:34pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/8 "2014-03-30T22:34:33Z")

</div>

Resolved. Stupid typo, but not in the code. Make sure in the input settings under Axis mappings (under edit-\>project settings) that there are no spaces in “MoveForward” and “MoveRight”

EDIT: Thanks Daerst…just saw your post =)

---

<div class="post-metadata">

**Author:** ![clu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@clu](https://forums.unrealengine.com/u/clu)\
**Post date:** [March 30, 2014, 10:49pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/9 "2014-03-30T22:49:05Z")

</div>

> [@ra\_ar;9246](#):
>
> Mine are:
> 
> ```auto
> 
> void AFPSCharacter::SetupPlayerInputComponent(UInputComponent* InputComponent)
> {
> 	
> GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("SetupPlayerInputComponent function called"));
> // set up gameplay key bindings
> InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
> InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);
> }
> 
> ```
> 
> Although as mentioned above I am not even getting the on screen message that the function is being called. All code in my project has been copy and pasted from the wiki and compiles without errors. I have verified that the inputs are named “MoveForward” & “MoveRight” in the editor - project - input section also.

ra\_ar, do you have OVERRIDE set on the SetupPlayerInputComponent declaration in FPSCharacter.h? Might be why it isn’t getting called at all.

```auto

	protected:
		virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) OVERRIDE;

```

The rest of my FPSCharacter.h is above in this thread, right underneath the screenshot I posted of the binding settings, in case it’s any help (my SetupPlayerInputComponent func is getting called no problem)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8bfa987f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8bfa987f1](https://forums.unrealengine.com/u/anonymous_user_8bfa987f1)\
**Post date:** [March 30, 2014, 11:04pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/10 "2014-03-30T23:04:47Z")

</div>

> [@ra\_ar;9246](#):
>
> Mine are:
> 
> ```auto
> 
> void AFPSCharacter::SetupPlayerInputComponent(UInputComponent* InputComponent)
> {
> 	
> GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("SetupPlayerInputComponent function called"));
> // set up gameplay key bindings
> InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
> InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);
> }
> 
> ```
> 
> Although as mentioned above I am not even getting the on screen message that the function is being called. All code in my project has been copy and pasted from the wiki and compiles without errors. I have verified that the inputs are named “MoveForward” & “MoveRight” in the editor - project - input section also.

I was thrown off here too. Make sure you click in the 3d viewport after clicking play. What I mean to say is; Compile your code, open your project, click play, then click in the 3d window where you see your map. I realized that the input was not working until your click in the viewport.

---

<div class="post-metadata">

**Author:** ![Star\_Dust](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Star\_Dust](https://forums.unrealengine.com/u/Star_Dust)\
**Post date:** [March 30, 2014, 11:05pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/11 "2014-03-30T23:05:08Z")

</div>

chu, yes it was set. I copied it straight from the wiki article. I’m going to continue along in the tutorial. Maybe there is something that has to occur later in regards to the camera to get this working?

---

<div class="post-metadata">

**Author:** ![Star\_Dust](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Star\_Dust](https://forums.unrealengine.com/u/Star_Dust)\
**Post date:** [March 30, 2014, 11:08pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/12 "2014-03-30T23:08:42Z")

</div>

> [@nickgamb;9266](#):
>
> I was thrown off here too. Make sure you click in the 3d viewport after clicking play. What I mean to say is; Compile your code, open your project, click play, then click in the 3d window where you see your map. I realized that the input was not working until your click in the viewport.

Thank you nickgamb, I have tried that though and it is still not working.

---

<div class="post-metadata">

**Author:** ![Star\_Dust](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Star\_Dust](https://forums.unrealengine.com/u/Star_Dust)\
**Post date:** [March 30, 2014, 11:44pm UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/13 "2014-03-30T23:44:32Z")

</div>

Ok, so I committed a dumb. Last night when I was compiling in VSE I had it using the “Development Editor”. Today when I continued the default option was “DebugGameEditor”.

Everything is working now that I selected the correct “Solutions Configurations” today. 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bfee94af](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bfee94af](https://forums.unrealengine.com/u/anonymous_user_bfee94af)\
**Post date:** [March 31, 2014, 1:22am UTC](https://forums.unrealengine.com/t/first-person-shooter-tutorial-wasd-problems/1435/14 "2014-03-31T01:22:38Z")

</div>

Haha I always hate that… 1 thing goes wrong and the whole thing doesn’t work! 😛
