Greetings.
Today in my evaluation of whether I can use UE4 as a platform to implement some ideas I have about using it to create a virtual world, I have found a road block that I quite do not understand for something I consider trivial and easy.
I am not yet highly familiar with how the UE4 C++ code implementation works, so I am trying to perform a simple task of calling a public function from one C++ Blueprint library I set up though the UE4 editor by another. I plan not to have these functions available as blueprint nodes in the editor. According to some documentation and a couple of youtube tutorials, I should be able to treat these as any ordinary c++ code. But when I compile the code I get the error
F:\Projects\Games\Voxel_CPP\Source\Voxel_CPP\Private\player\User_BPFL.cpp(10) : error C2248: 'UCameraComponent::UCameraComponent': cannot access private member declared in class 'UCameraComponent'
The Code this is referring to is the public function get_camera_direction_vectors in camera_BPFL.h
UCLASS()
class VOXEL_CPP_API Ucamera_BPFL : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
Fmovement_struct_type get_camera_direction_vectors(UCameraComponent camera);
};
camera_BPFL.c
Fmovement_struct_type Ucamera_BPFL::get_camera_direction_vectors(UCameraComponent camera) {
Fmovement_struct_type camera_direction;
FMinimalViewInfo camera_view;
UKismetMathLibrary ml;
camera.GetCameraView(0,camera_view);
camera_direction.forward_movement_vector = ml.GetForwardVector(camera_view.Rotation);
camera_direction.side_movement_vector = ml.GetRightVector(camera_view.Rotation);
camera_direction.up_movement_vector = ml.GetUpVector(camera_view.Rotation);
return camera_direction;
}
and camera.GetCameraView is a public function within UCameraComponent as far as I can see.
This is called within the public function initialise_camera_direction_vectors of file User_BPFL.cpp
Fmovement_struct_type Uuser_BPFL::initialise_camera_direction_vectors(UCameraComponent camera) {
Ucamera_BPFL camera_BPFL;
Fmovement_struct_type initial_movement_direction = camera_BPFL.get_camera_direction_vectors(camera);
return initial_movement_direction;
}
My C++ experience tells me this should compile, (as it does if the code of get_camera_direction_vectors is in User_BPFL.cpp without a function call) but when I last touched UE C++ some 18 months ago, I found it to be particularly fussy and very sensitive to trying to introduce or modify code it did not generate. So I exited the project as I thought something may have messed up with the editor or visual studio 15 and restart the project. I then got the following.
the following modules are missing or built with a different engine version
UE4Editor-Voxel_CPP.dll
would you like to rebuild them now?
So naturally I said yes and got
Voxel_CPP could not be compiled. Try rebuilding from source manually.
This is the second time this has happened today. Not sure why.
Am I doing something fundamentally wrong or is it that UE4 cannot handle simple C++ fuction calls outside its strict macro regime?
The reason I am doing this is because I cannot find any C++ function that is equivalent to the vector functions GetforwardVector, GetRightVector and GetUpVector that exist as Blueprint nodes as shown blow.
Any help would be appreciated.