I’m learning C++ at the moment, And I’m trying to convert a Blueprint code to C++. My Event Update Room Scale Position is implemented as BlueprintImplementableEvent and BlueprintCallable. So I can Implement the event in the blueprint. Here is the Image of the Blueprint.
Now I am trying to covert this blueprint code to c++
Here is the Function in the .h file
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character Movement")
FVector LastRoomScalePosition = FVector(0.f,0.f,0.f);
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Character Movement")
void UpdateRoomScalePosition();
and in the .cpp file
void ABasePawn::UpdateRoomScalePosition()
{
FRotator DeviceRotation;
FVector DevicePosition;
UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(DeviceRotation,DevicePosition);
FVector Position = LastRoomScalePosition - (DevicePosition.X, DevicePosition.Y, 0.f);
CapsuleComponent -> AddWorldOffset(FVector(Position), false, nullptr, ETeleportType::None);
LastRoomScalePosition = FVector(DevicePosition.X, DevicePosition.Y, 0.f);
}
I don’t know if this is correct way of how the code is as I used docs and searching google to workout how to construct the c++ code.
But when I build the code I get these errors
BasePawn.gen.cpp.obj : warning LNK4006: “public: void __cdecl ABasePawn::UpdateRoomScalePosition(void)” (?UpdateRoomScalePosition@ABasePawn@@QEAAXXZ) already defined in BasePawn.cpp.obj; second definition ignored
BasePawn.gen.cpp.obj : error LNK2005: “public: void __cdecl ABasePawn::UpdateRoomScalePosition(void)” (?UpdateRoomScalePosition@ABasePawn@@QEAAXXZ) already defined in BasePawn.cpp.obj