Announcement

Collapse
No announcement yet.

Rotate Mesh on MouseClick

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

    Rotate Mesh on MouseClick

    Hey,

    Am currently working on adding a turret I made, so far I've got it imported and I've followed this tutorial to figure out how to be able to look left/right and up/down. It's been going pretty smooth so far, but I've hit a dead end.

    Basically what I'm working on is a Phalanx CIWS. I've added an InputAction for LeftMouseButton, and I'm trying to figure out how to make the barrels(it's a StaticMesh) rotate as I click the left mousebutton.

    It might be worth noting that I am new to working with UE, and this whole FlowGraph thing is new to me. If anyone has some advice or pointers, I'd greatly appreciate it.

    Example of what it currently looks like, if it is of any help;
    Attached Files

    #2
    So assuming the barrels are a component of that Phalanx thing, you'd simply drag that component into the Blueprint and do a rotation on it, something like this:

    Click image for larger version

Name:	barrelBP.png
Views:	1
Size:	28.3 KB
ID:	1053579

    Inside the Timeline it would look something like this:

    Click image for larger version

Name:	timelineBP.png
Views:	1
Size:	16.7 KB
ID:	1053580

    Basically a key at 0 secs and value 0 and another at 2 secs (or whatever to achieve the desired speed) with value 360. Set it to looping and the same length as the second key.

    Comment


      #3
      Okay, now it does something. The barrels don't spin, though. As soon as I click the mousebutton, the camera rotates 180 degrees and if I try to look around whilst holding it down - it just goes bonkers. Might it have something to do with the fact the camera is a child of the barrels?
      Last edited by Dealman; 08-17-2014, 11:54 PM.

      Comment


        #4
        You'll get used to it and find it actually makes a lot of sense. You want to set the rotation of you barrel, so of course you would drag out from that and see what's available. You will then only see relevant nodes that will actually work for your component. So first think of what you want to manipulate, get a reference to that and then find about how you can manipulate it.

        Comment


          #5
          Originally posted by Dealman View Post
          Okay, now it does something. The barrels don't spin, though. As soon as I click the mousebutton, the camera rotates 180 degrees and if I try to look around whilst holding it down - it just goes bonkers. Might it have something to do with the fact the camera is a child of the barrels?
          If you attach the camera to the rotating barrel, the camera is going to spin.

          Comment


            #6
            I tried attaching it to the Turret part instead, and it was better. However, so long as the mousebutton is held down - the barrel does not follow the rotation of the turret. Suggestions?

            Comment


              #7
              Originally posted by Dealman View Post
              I tried attaching it to the Turret part instead, and it was better. However, so long as the mousebutton is held down - the barrel does not follow the rotation of the turret. Suggestions?
              SetWorldRotation sets the barrels rotation in world space. You want SetRelativeRotation, and then on just the axis the turret spins around.

              Comment


                #8
                Ah, that makes sense... Thanks for helping a rookie out guys, I really appreciate it! This timeline sure will come in handy, will try to use it for my sound assets as I was trying to use timers at first, but couldn't get it to work.

                Comment


                  #9
                  Originally posted by Dealman View Post
                  Ah, that makes sense... Thanks for helping a rookie out guys, I really appreciate it! This timeline sure will come in handy, will try to use it for my sound assets as I was trying to use timers at first, but couldn't get it to work.
                  Did you get it working?

                  Comment


                    #10
                    Aye, it's working. We've got spool up and spool down working as well!

                    Comment

                    Working...
                    X