I created this blueprint to make a block move up and down, I’m just trying to get it to move down at the moment though, but it thinks it’s an infinite loop when it isn’t? Does anyone know what’s going on?
It is an infinite loop, and there are several problems:
Simple Move To Location works on controllers, and you don’t have one as a target. You should use Set Actor Location for moving non-pawn actors instantly. In this case, you aren’t moving anything at all, so the While-loop never completes. Not sure what Simple Move To Location is even used for.
I don’t know the initial starting position of this actor, but the make vector is subtracting from the actor’s position, and the condition check (float =! float) is a positive number. So if the Z starting position is under 110 (world location), the actor moves away from it, and the condition never becomes true. Also, you are checking a very specific value, instead of a more general check, like greater than or lesser than. Which means if it’s initial position is for example 1000.25, it can never reach exactly 110, only 110.25.
There is a limit to the number of iterations that a While-loop can carry out. Not sure how many, but it’s fewer in BP than in C++. A loop is considered infinite if it doesn’t complete within that number of iterations. Usually if you are hitting that limit, there is a better way to do what you are trying to do.
A While-loop carries out within the same tick. In your case, this would mean the block would move instantly to it’s end position. If you then do the same for the way back, it’d also move instantly back to it’s original position. I assume you want a smooth movement over time, so this method won’t ever work since it would just oscillate between the two spots quicker than you can see it (I think this would be considered an infinite loop too).
There are many better ways to approach what you are trying to do, depending on what you are trying to do. This tutorial shows one way, using Matinee: - YouTube. Here’s another one: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums. It’s also possible to have it pure BP, using a Timeline that moves it between 2 positions over time.
Thank you, that tutorial was really helpful