When binding methods in unreal C++, you can use the ThisClass
typedef rather than using your classes name, this works like Super
, both typedefs are created in the GENERATED_BODY()
macro. Also, its since it’s safe to refer to parent class members from the child classes scope unless you trying to access an overridden functions you can actually set up input binding as follows:
PlayerInputComponent->BindAxis(TEXT("MoveX"), this, &ThisClass::MoveX);
PlayerInputComponent->BindAxis(TEXT("MoveY"), this, &ThisClass::MoveY);
PlayerInputComponent->BindAxis(TEXT("LookPitch"), this, &ThisClass::AddControllerPitchInput);
PlayerInputComponent->BindAxis(TEXT("LookYaw"), this, &ThisClass::AddControllerYawInput);
This has the advantage of not having to change binding when you copy them to another class or rename your class.