Announcement

Collapse
No announcement yet.

Help with simple while loop.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:

    Code:
    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.

    #2
    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.
    Daniel Broder
    Senior Gameplay Programmer, Epic Games

    Comment


      #3
      Originally posted by Daniel Broder View Post
      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.
      Heh. I know that. I was having trouble with hooking up the variables to the whileloop node and decrementing it.

      Comment


        #4
        Originally posted by unrealego View Post
        Heh. I know that. I was having trouble with hooking up the variables to the whileloop node and decrementing it.
        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.

        Comment


          #5
          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)

          -Mike

          Comment


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

            https://docs.unrealengine.com/latest...nes/index.html

            Comment


              #7
              Originally posted by zorque View Post
              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
              -Mike
              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.
              Last edited by unrealego; 03-28-2014, 04:12 PM.

              Comment

              Working...
              X