If statements are the equivalent to a branch node in blueprints
So it will say if we do this execute this code, else execute this other code or do nothing.
We still need to find the distance we moved so we are going to create in our header a float of moveddistance. We also are going to comment out our DistanceMoved variable. Back over in the cpp just add float infront of Distance Moved.
We are now going to write an if statement saying that if our distance moved is greater than our move distance make the platform velocity go negative.
If we hit play we will see our platform goes forward and backward, but it goes past the starting location.
We are now going to update the startLocation inside the if statment and setting it to the currentLocation
Our cube now resets when it gets back to it’s origin location and starts moving again.