Unreal Engine - Rotate object/character with button or mouse drag

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ต.ค. 2024
  • In this video we look at how to rotate the object or character mesh using a widget button or mouse click and drag events.
    Note there's a similar approach which also handles zoom here: • Unreal Engine - Handle...
    And approach using spring arms: • Unreal Engine - zoom a...
    All the steps to achieve this can be found on this blog post here:
    unreal-mmo-dev...
    Feel free to drop down to the new discord channel to ask any questions here: / discord
    In the next video I will look to finish and describe the content in this character selection screen a little more as it uses complex modular character meshes.

ความคิดเห็น • 44

  • @samohickey
    @samohickey 9 หลายเดือนก่อน

    Great tutorial! Thank you. :D Very thorough; love how you even show how you reference other classes! That's where most people get stuck.

  • @hassanalhobail8084
    @hassanalhobail8084 3 หลายเดือนก่อน

    There is a point I want to add to ensure it works for everyone as well:
    We need to have the input mode set to UI and Game, because otherwise, the on clicked event requires double click to register

  • @danielgiambattistelli7380
    @danielgiambattistelli7380 หลายเดือนก่อน

    Thank you so much this tutorial saved me!!!!

  • @barobaparthoens7887
    @barobaparthoens7887 11 วันที่ผ่านมา

    Thanks for the tutorial, it has helped me a lot understanding UE5 a bit more. I have make a similar setup, but without an UI and just a rotating platform. It is just not rotating. The part that is missing is that you connect the 'Enable Input'-node to a part of your UI. Which I can not do, because I have none. Now I have no idea where to put it? Can you help me out?
    Thanks in advance.

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  10 วันที่ผ่านมา

      hey :)
      Enable input is for actor blueprints - is your platform a part of actor/pawn class?
      if not, perhaps you may want to reparent it to become an actor or pawn and then you can get access to this 'enable input' function
      (for example creating an empty actor BP and setting the platform as the skeletal mesh) you may also want to leverage the 'child actor' component from the components view in your platform BP, to make sure the rotation affects the character/object as expected

      if you don't need to capture the events directly off the platform component but anywhere on the screen, you can make the rotating logic inside the game controller BP for example
      but doing it off the actor component is more desirable in most cases

  • @decorix
    @decorix ปีที่แล้ว +1

    Thanks so much. What a great tutorial. I'm doing the mouse part. I only have BP_Cube and inside the BP I have (cube_mesh) + set ScrollCylinder as well. I followed all the steps, but it's not rotating my cube? :-( Do you perhaps have any idea? I have setup the GameController and turned everything on.

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      hey :)
      I'm assuming you've followed all the steps here?
      unreal-mmo-dev.com/2022/06/03/15-ue-rotate-object-by-click-drag-in-blueprints/
      One of the very last steps is the 'enable input' on the actor with the player controller, have you done that part too?

  • @danielgiambattistelli7380
    @danielgiambattistelli7380 หลายเดือนก่อน

    This worked wonderfully. But I was wonder if its possible to have the same rotation with an input touch. I tried several things but none worked as I expected. I can solve simple blueprint things but I guess that is out of my comprehension.

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  หลายเดือนก่อน

      hey :)
      so it sounds like you want to use the functions:
      - on input touch begin
      - on input touch end
      - on input touch leave
      which are part of the cylinder component events
      have you tried using those?

  • @siMM4tw
    @siMM4tw 3 หลายเดือนก่อน

    it works! thanks a lot! only took me half an hour!

  • @jmiller6676
    @jmiller6676 หลายเดือนก่อน

    Thank you Yaz!

  • @anlar1998
    @anlar1998 8 หลายเดือนก่อน

    I did the same thing but my actor wasnt rotating, i dont know why but maybe because it has capsule component capsule as root. It wasnt working. So i created empty actor without capsule component and it worked there.

  • @julianescholz3929
    @julianescholz3929 9 หลายเดือนก่อน

    Hey! Thx for the Tutorial. I have a question regarding the cam movement. You mentioned in 1:55 that you can block the camera movement. Thats exactly what I want. When I hit play, the cam will still rotate. is there any other way to lock the camera rotation?

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  9 หลายเดือนก่อน

      I'm assuming you mean the default behaviour of your character controller.
      you will want to create a new character controller blueprint, in my case its 'CreateCharacterController' and click the buttons to show the mouse cursor and enable click events etc.
      its covered in the attached doc with screenshot
      unreal-mmo-dev.com/2022/06/03/15-ue-rotate-object-by-click-drag-in-blueprints/
      then you'll want to link it to game either linking it in used game mode or world settings override for your map
      good luck!

  • @Knooblegooble
    @Knooblegooble ปีที่แล้ว

    Simple, works like a charm. Thanks!

  • @bebachkin
    @bebachkin 2 ปีที่แล้ว +2

    Thank You so much!

  • @autodriv3r405
    @autodriv3r405 8 หลายเดือนก่อน

    Just a quick question: How does this work when the Widget is on Z, on Top, over the Character. Mhh....

  • @edespelder
    @edespelder ปีที่แล้ว

    This was super helpful! I’m wondering if it’s possible to rotate multiple actors around their local pivots via a single input on any one of them using this? I’m trying to set up turntable to compare three things at once but they need to turn in unison. Thanks!

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      hey :)
      yep, that sure is possible
      you'd want to do evaluation for rotate velocity a layer above the actor blueprint, such as player controller
      and inside the player controller you will want to have references of all actors
      when you process the drag (through whichever means), you update the params in the controller which pushes them (mainly 'rotate velocity'), onto the actor blueprints (through the references)
      so therefore the event tick inside the actors will have handle rotation, where the velocity is provided by the controller class - making it consistent across them.
      hope that made sense!

  • @pratyushraut9120
    @pratyushraut9120 ปีที่แล้ว +1

    I am trying the method of rotating an actor with buttons but always getting an error
    "Accessed None trying to read property Imperial Shuttle Rfence". Node: Add Actor World Rotation Graph: EventGraph Function: Execute Ubergraph Rotate Imperial Shuttle Blueprint: Rotate_Imperial_Shuttle

    • @pratyushraut9120
      @pratyushraut9120 ปีที่แล้ว

      imperial shuttle is the actor i want to rotate,
      need help fast 🥲

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      Accessed none will usually refer to a NPE (null pointer exception)
      So basically the variable is not set with the actual param.
      Have a look at how you're setting that parameter up, there's likely something wrong, add a breakpoint and perhaps isValid with switch statement on the variable to confirm when you click the rotate button.
      One hacky solution / quick fix is to find the actor(s) by class and set it, just before handling the rotation

    • @pratyushraut9120
      @pratyushraut9120 ปีที่แล้ว

      @@unreal-dev-with-yaz hi thankyou soo much!! it works! ( to an extent )
      just a one more problem ,
      Now that I am using the button to rotate it everytime I cik the button its making a new copy
      ( I hope I am not causing much inconvenience , (beginner problem🙂))

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      @@pratyushraut9120 👋
      I'm not sure what you mean
      New copy of the actor? On the button click you need to get a reference to the actor, then rotate that actor by set amount
      If you're creating new actor, perhaps you're calling wrong function, to spawn actor of class, instead of getting one from the map.

    • @pratyushraut9120
      @pratyushraut9120 ปีที่แล้ว

      @@unreal-dev-with-yaz yes everytime a new actor i being created

  • @gamedevGod
    @gamedevGod 2 ปีที่แล้ว +2

    NIce tutorial!😉

  • @mystang154
    @mystang154 ปีที่แล้ว

    Great tutorial! I could make the scene actor rotate with mouse input using this procedure with "OnClicked" event and the condition "isDragging". But once I release the click and re-click on the same actor, it no longer rotate. It only rotates the first time I click on it. I can't figure out what's going wrong. For info: the actor is appearing on scene with "get actor of class" node when we click on a widget button. To re-enable the rotation, I need to re-click on the widget button, which is not what I want. Thank you!

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      you may want to add some debugging to it as hard to tell what's wrong without looking into the BP.
      so add some print strings to on button pressed / release, maybe also printing the states of the variables, in particular the booleans
      for instance, checking the states of isDragging or rotateChar (or equivalent) is as expected
      also add some breakpoints and step through the functions, making sure the flow is correct :)
      perhaps there's some variables which are not being reset as expected

    • @mystang154
      @mystang154 ปีที่แล้ว +1

      @@unreal-dev-with-yaz Thx very much for such a quick reply! After exposing my problem to your channel I tried one last thing and it finally fixed the issue. It's now working exactly as expected. By error I chose to set the input mode node to "Game Only" after clicking the widget button to get the actor while it should have been set to "Game and UI". It was simple as that. Your bp solution for mouse input rotation works extremely well and I like the flexibility it provides. Cheers!

    • @siMM4tw
      @siMM4tw 3 หลายเดือนก่อน

      @@mystang154 Thank you! I´ve had the same issue

  • @凡尘-m7h
    @凡尘-m7h ปีที่แล้ว

    Where should I rotate the mouse? I'm not sure how to enable input at the end (Sorry, I'm a beginner). I've written the previous blueprints, but I'm stuck on the last step.

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      hey :)
      not fully clear - do you mean that your event click listeners are not activating when you click with your mouse?
      is your blueprint a 'skeletal mesh actor' ? it may not work as expected with 'Character' blueprints as they consume input differently.
      The last part of enabling the input is shown here too: unreal-mmo-dev.com/2022/06/03/15-ue-rotate-object-by-click-drag-in-blueprints/
      You grab the reference of your skeletal mesh actor and using the pin from it, call function 'Enable Input' - specifying current player controller

    • @凡尘-m7h
      @凡尘-m7h ปีที่แล้ว

      @@unreal-dev-with-yaz Thank you very much for your response. I will study and try it out. Thank you😁

  • @jameshill2043
    @jameshill2043 ปีที่แล้ว

    Has anyone made a BP that would do all of this but enable free 360 rotation of an object? Or a tut on how to expand this?

    • @kevinvonbriel
      @kevinvonbriel 9 หลายเดือนก่อน

      guess you are just capturing the Y coordinates aswell and calculate it via the direction vector you're looking to the object

  • @cameoartworks3179
    @cameoartworks3179 ปีที่แล้ว

    pls make step by step tutorial on how to rotate object

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  ปีที่แล้ว

      hey
      all the step by step instructions are in my descriptions in the docs
      for this video: ylazarev.com/2022/06/03/15-ue-rotate-object-by-click-drag-in-blueprints/

  • @SwordWieldingDuck
    @SwordWieldingDuck 2 ปีที่แล้ว

    Why you are not getting infinite loop at around 3:51?

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  2 ปีที่แล้ว

      at 4.15 is where it's described - the loop is broken when you disable the `rotate char` Boolean. The Boolean is disabled when you let go of the button, i.e. `on button released` event.

    • @SwordWieldingDuck
      @SwordWieldingDuck 2 ปีที่แล้ว

      @@unreal-dev-with-yaz i tried the same thing, but it does give me Infinite Loop error.

    • @unreal-dev-with-yaz
      @unreal-dev-with-yaz  2 ปีที่แล้ว

      @@SwordWieldingDuck can drop into discord and share a screenshot of the blueprints to have a look at discord.gg/9KvdVdJahH