Scope Resolution Operator
We are now going to see how much our moving platform has moved and display it in the editor.
To check how far we moved we need to find the distance between 2 vectors and how to keep track of where we started from. We are going to head back over to our header.
FVector called StartLocation
Back in our cpp file, in our BeginPlay function. We are going to set our startlocation = our actor’s location
- Scope Resolution Operator — (::) Looks inside a class as the same way a dot operator allows you to look inside an instance of a class.
We know Tick belongs to the movingplatform class
This is saying the tick operator belongs to the moving platform class.
To get the distance between 2 FVectors::Dist(,)
The distance between the starting location and our current location is what we are trying to find.
We head back over to the header file and create a distance moved float.
We set DistanceMoved = FVector::Dist(StartLocation, CurrentLocation) this is giving us our distance moved in Units.
You can see the distance moved is increasing as the cube moves farther away.