Help with simple while loop.

Ok, I’ve looked at the docs, but I can’t seem to get this working.

I have a cube and I just want it to rotate 90 degrees on the z-axis while a number is not zero.
So in pseudo code its:



num = 10
while(num > 0)
   rotate cube 90 degrees
   num--


Simple yeah? For the life in me, I can’t seem to find all the correct nodes to make this work in BluePrint.

If you right-click and type “while” in context, you should get a node called WhileLoop, which would let you do what you want. You can also use ForLoop potentially. :slight_smile:

If you right-click and type “while” in context, you should get a node called WhileLoop, which would let you do what you want. You can also use ForLoop potentially. :slight_smile:
[/QUOTE]

Heh. I know that. I was having trouble with hooking up the variables to the whileloop node and decrementing it.
:rolleyes:

Is your question how you would decrement every tick?

While I’m a complete noob, have you looked into using the “Add” node and using a negative number? Without being at home to reference, is there then a subtract node? So:

(Var 10) -> (While >0) -> (Add -1)

When you define variables do you need to insert a Constant 1 and set it to 10? Without having the editor up and having only started tooling around last night, I’m likelye more noise than assistance.

So I wasn’t sure WHY you’d want to do this in a while loop instead of just rotating the cube 90 * your number, but here’s a working example that you should be able to pull your logic out of:


(Note: I was rotating by 45 degrees, not 90, so I could verify the rotation visually)

Hey, if you’re working on a simple animation, probably timelines will be more convenient.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Timelines/index.html

No reason at all, except I just wanted to explore BluePrints thats all. Coming from a programming background, I just wanted to “code” in BluePrints.
But maybe I’m looking at BluePrints the wrong way?

Thanks for all your inputs people.