MoveToLocation C++

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;
}



// Update call as follows




FVector Destination;
GetRandomPos(Destination);
MoveToLocation(Destination);