How to keep the variables private

uem_s04_client_interpolation_mesh_offset

#1

Hi,

In the video, at about 7:30 mark, we’ve moved some of the variables into the public section, and Sam asked if there’s a way to avoid it. The variables can be kept in the private section if we use UPROPERTY’s meta specifier AllowPrivateAccess. In our case it looks like this:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UGoKartMovementComponent* MovementComponent;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UGoKartMovementReplicator* MovementReplicator;

I kept the two variables in the private section of the header file, after adding the meta specifier, and the code compiles and executes as expected.

Here’s a list of other meta specifiers, for reference.


#2

Nice one! Keep up the good work and sharing it with other students.