Why we need UPROPERTY()

Hi, I wonder why we need UPROPERTY() for components?

	UPhysicsHandleComponent* PhysicsHandle = nullptr;
	UInputComponent* InputComponent = nullptr;

It is empty, what does it do?

It’s to be counted for by garbage collection

Without it the garbage collector could potentially be collected whilst you’re still using it. For components that’s rather unlikely as the actor it’s attached to should hold a reference to it but it’s good to get into the habbit of it.

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

Privacy & Terms