My goal is to define movement keys to move an object (W,A,S,D,Q,E). In the default mode I want these inputs to act like axes (continuous input). But I want to be able to toggle these inputs to do step movements (e.x.: pressing W will move the object 10 units forward while in ‘step’ mode but will move continuously forward in the default mode).
I know I can do something like this
InputComponent->BindAxis("MoveForward", this, &MyClass::MoveForward);
And then in the MoveForward method (partly pseudo code):
void MoveForward(float value)
{
if(InputMode == StepMove) {
if(value > 0.9f && !isForwardDown) {
isForwardDown = true;
Translate(10, 0, 0); // move 10 units along the X axis
} else {
isForwardDown = false;
}
} else {
// move 'MovementSpeed' units per second along the x axis
Translate(value * MovementSpeed * DeltaTime, 0, 0);
}
}
But it would be much easier to have two move forward methods, one for axis input and one for action input on the same Key and then toggle between them. How would I go about toggling between the two if at all possible?