Im making a turret that rotates with e,q. I made it a pawn and already made the inputs on project settings.
This is my code:
void ATurret::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
InputComponent->BindAxis("TurretRotate", this, &ATurret::Turn);
}
void ATurret::Turn(float amount) {
rotator.Yaw += amount;
SetActorRotation(rotator);
}
Any idea on why its not rotating, if i move de function Turn to Tick it does spin. They inputs are an axis called TurretRotate so i dont get what im doing wrong.
Can’t you just rotate it in the blueprint?
My guess is that you have a wrong input setup because as you say if you move the function into the Tick it does work. So you need to double check the input setup, you added a binding for the axis but did you also add a binding for the key that will control the axis?

You can see that I mapped the MouseX with a scale of 1, that will return values from 1.0f to -1.0f into the function.
I added E with 1.0 scale and Q with -1.0. Maybe the problem is im using keys and not a axis per de as a mouse or joystick?
Hmm no that is fine, the only difference is that you will only get 1.0f or -1.0f, nothing in between.
I also tried whith gamepad axis and mouse, and with location and not rotation. still nothing, so i dont know what the problem is.