hello,
I am new to c++ and UE4 and i have a question.
I made an AI character and controller and I am trying to move him to a random Fvector In a certain radius.
my question is how do i set up the functions in the c++ because the MoveToLocation takes a const fvector&.
i know its kind of a novice question but like i said i am new to the engine and language.
The following does not call the function but rather gets the function’s address in memory. Your trying to pass the functions memory address as a parameter to MoveLocation instead of an FVector.
// Get address of GetRandomPos function, this is not a function call
MoveToLocation(&AAI_Zombie_Controller::GetRandomPos);
To use a reference with GetRandomPos you’d have to change the code I wrote above as follows. There is no return in this case.
// In header
GetRandomPos(FVector& MyRandomVector) const;
// In cpp
AAI_Zombie_Controller::GetRandomPos(FVector& MyRandomVector) const
{
// My random vector implementation goes here
MyRandomVector = UpdatedFVectorValue;
}