How do i access private variable without putting them to public?

For example -
i have this ProjectileSpawnPoint and i need to use it in Tower.cpp how can i do that?

You can use the “AllowPrivateAcess” meta property to allow blueprints to access the variable even if it’s set to private in the c++ file.

	UPROPERTY(Category = "MyStuff", EditDefaultsOnly,BlueprintReadWrite,meta=(DisplayName = "The Start Delay", ClampMin = "0", ClampMax = "30", AllowPrivateAccess = "true"))

oh wait that wont help in this case as that will only help iwth blueprints.

Where is ProjectileSpawnPoint declared?

If it’s delcared in the parent class of this class - you should remove it from private and put it in the ‘protected’ area in the header file - that allows children of the class to see it.

Make it protected or provide a public getter.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms