In deceleration file .h I declare properties:
ATriggerVolume* PressurePlate;
AActor* MyActor;
Why I need to use * here ?
In deceleration file .h I declare properties:
ATriggerVolume* PressurePlate;
AActor* MyActor;
Why I need to use * here ?
As I understand it, it’s because it needs to be one and the same object at all times. When you use a pointer, you pass its value by reference, so you can have multiple variables referring to the same object.
Let’s say you create AActor* MyActor; but then you want to store it in a different variable for some reason: AActor* MyNewActor = MyActor; In this case both variables will refer to the same object, and if you change anything by the initial variable, it will be reflected in the second variable.
When you declare a variable that’s not a pointer, it’s different. E.g.:
int32 i = 3;
int32 j = i;
i = 5;
In this case you’ll have i = 5 and j = 3; But a pointer refers a unique object. And anything that you can add to your map must be referred to via a pointer.