Move to move forward when pressing left and right mouse button at the same time in c++?

in your blueprints you ware using AXIS instead Action (buttons) anyway in C++ should be like this:

InputComponent->BindKey(EKeys::LeftMouseButton, IE_Pressed, this, &AYourActor::LeftButtonFunction);

you can put that in the beginplay of your actor with the other bindings)

LeftButtonFunction is the function you want to run when leftMouseButton is PRESSED

do the same for rightMouseButton and another binded function

same for release (IE_Released)

then you can have 2 bool variables: LMB and RMB…
in the pressed functions set the corresponding to true and in the release to false.

Then the condition is if (RMB && LMB) to add movement input

2 Likes