I dont understand the logic

I want to really understand how it works. My code shows the stage I’m currently in. It is about moving platform. I don’t understand why it fully goes back when we reach the maximum point of distance, instead of just going back a little bit, become less than distance again, and start from that point? What makes the platform work as we want it to?


p.s. this code works

1 Like

here everything works, but I just dont understand why

1 Like

and no matter do I include the 43 or not, it works basically well, just different in length

Because you’re making the start location the current location.

Example:

StartLocation = (0, 0, 0)
MoveDistance = 100

Tick 100:
CurrentLocation = (95, 0, 0)
if (Dist > MoveDistance) # 95 > 100
...
Tick 101:
CurrentLocation =  (105, 0, 0)
if (Dist > MoveDistance) # 105 > 100
StartLocation = (105, 0, 0)

So now from this point on you’re going backwards (towards 0,0,0) and working out the distance between (105, 0, 0) and the current location. When you get to 0,0,0 the distance would be greater than 100.

1 Like

I think I got that, thanks!

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

Privacy & Terms