I’m following along the updated Battery Collector series, and currently on video #5. There is one line in the video that I do not understand. In the
ABatteryPickup class that inherits from
APickup, in the constructor
ABatteryPickup::ABatteryPickup() there is one single line:
So I hopped up on Unreal Docs and
SetSimulatePhysics() are both understandable. What I don’t understand is the
-> operator. What does it do?
“->” is called “Member Access” and in the simplest terms it allows you to access members of the object referencedy the pointer.
If YourClass has the following properties:
// A float variable
// A function that returns nothing and takes no parameters
and you have a pointer to an instance of YourClass, e.g.
You can access the float variable and the function belonging to YourClass:
// Set variable
PointerToInstanceOfYourClass->MyClassFloat = 5.0f;
// Execute function
It is analogous to the “.” operator, but for pointers.