# Can you change the movement controls of the top down template using C++?

**URL:** <https://forums.unrealengine.com/t/can-you-change-the-movement-controls-of-the-top-down-template-using-c/343230>\
**Category:** Character & Animation\
**Tags:** UE4-9, top-down-template, unreal-engine, question, CPP\
**Created:** [January 6, 2016, 12:00am UTC](https://forums.unrealengine.com/t/can-you-change-the-movement-controls-of-the-top-down-template-using-c/343230 "2016-01-06T00:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_6807658a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6807658a](https://forums.unrealengine.com/u/anonymous_user_6807658a)\
**Post date:** [January 6, 2016, 12:00am UTC](https://forums.unrealengine.com/t/can-you-change-the-movement-controls-of-the-top-down-template-using-c/343230/1 "2016-01-06T00:00:37Z")

</div>

Is it possible to change movement controls in the top-down template from point and click to WASD using C++? If so, how would this be achieved?

---

<div class="post-metadata">

**Author:** ![5Kwatts](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@5Kwatts](https://forums.unrealengine.com/u/5Kwatts)\
**Post date:** [January 6, 2016, 1:41am UTC](https://forums.unrealengine.com/t/can-you-change-the-movement-controls-of-the-top-down-template-using-c/343230/2 "2016-01-06T01:41:03Z")

</div>

Hi Waydims,

It is possible.

In the Controller class, you need to create two BindAxis calls to InputComponent that set your two movement functions (one for up/down and another for left/right). In your Input file assign the W/S key to your named functions with a scale of 1 for forward/up and -1 for down. Do the same for left/right with A/D.

Note that what I have below is almost identical to what you would see if you made a third person/first person c++ template as that is where I based mine off of before I fine tuned it.

In the two movement functions, put the following:

```
if (value == 0.0f)
		return;

	// find out which way is forward
	const FRotator rotation = GetControlRotation();
	const FRotator yawRotation(0, rotation.Yaw, 0);

	// get forward vector
	const FVector direction = FRotationMatrix(yawRotation).GetUnitAxis(EAxis::X); //<- change X to Y on the left/right function
	if (GetCharacter())
		GetCharacter()->AddMovementInput(direction, value);
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6807658a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6807658a](https://forums.unrealengine.com/u/anonymous_user_6807658a)\
**Post date:** [January 6, 2016, 5:11am UTC](https://forums.unrealengine.com/t/can-you-change-the-movement-controls-of-the-top-down-template-using-c/343230/3 "2016-01-06T05:11:44Z")

</div>

Thanks alot, it worked like a charm!
