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

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?

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)

	// 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);

Thanks alot, it worked like a charm!