# How to map actions and axis in player controller if possibl

**URL:** <https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364>\
**Category:** Character & Animation\
**Tags:** axis-mappings, unreal-engine, action-mappings, question, CPP\
**Created:** [June 11, 2015, 6:19am UTC](https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364 "2015-06-11T06:19:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gogata258](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gogata258](https://forums.unrealengine.com/u/gogata258)\
**Post date:** [June 11, 2015, 6:19am UTC](https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364/1 "2015-06-11T06:19:34Z")

</div>

is it possible to map actions and axes in the player controller rather than in the character, and if yes can someone explain the process of doing it.

---

<div class="post-metadata">

**Author:** ![MulleDK19](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MulleDK19](https://forums.unrealengine.com/u/MulleDK19)\
**Post date:** [June 11, 2015, 11:12am UTC](https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364/2 "2015-06-11T11:12:39Z")

</div>

C++ or BP?

---

<div class="post-metadata">

**Author:** ![gogata258](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gogata258](https://forums.unrealengine.com/u/gogata258)\
**Post date:** [June 11, 2015, 12:12pm UTC](https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364/3 "2015-06-11T12:12:06Z")

</div>

c++ would be of preference

---

<div class="post-metadata">

**Author:** ![MulleDK19](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MulleDK19](https://forums.unrealengine.com/u/MulleDK19)\
**Post date:** [June 11, 2015, 12:39pm UTC](https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364/4 "2015-06-11T12:39:54Z")

</div>

Not only is it possible, it’s where it should be. Override SetupInputComponent in your player controller and do all the bindings there.

Eg. (pseudo):

```
void AMyPlayerController::SetupInputComponent()
{
	Super::SetupInputComponent();

	this->InputComponent->BindAction("Walk", EInputEvent::IE_Pressed, this, &AMyPlayerController::OnWalkStart);
	this->InputComponent->BindAction("Walk", EInputEvent::IE_Released, this, &AMyPlayerController::OnWalkEnd);
}

void AMyPlayerController::OnWalkStart()
{
	AMyCharacter* character = Cast<AMyCharacter>(this->GetCharacter());
	if (character)
	{
		character->SetWalking(true);
	}
}

void AMyPlayerController::OnWalkEnd()
{
	AMyCharacter* character = Cast<AMyCharacter>(this->GetCharacter());
	if (character)
	{
		character->SetWalking(false);
	}
}
```

---

<div class="post-metadata">

**Author:** ![gogata258](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gogata258](https://forums.unrealengine.com/u/gogata258)\
**Post date:** [June 11, 2015, 12:45pm UTC](https://forums.unrealengine.com/t/how-to-map-actions-and-axis-in-player-controller-if-possibl/321364/5 "2015-06-11T12:45:52Z")

</div>

Thanks you a lot for the example
