enter image description here

I made this cube in ue4..now I am able to rotate cubes separately without any problem.

But how do I move a row of cubes in response to mouse drag..

How do I detect what row is selected when my mouse is clicked and dragged on only one cube

  • 2
    \$\begingroup\$ There is a button called "Print screen" or "Prt Scr", use it next time you want to post an image (Print screen -> paint -> Ctrl + V -> save) \$\endgroup\$
    – Bálint
    Dec 12, 2016 at 13:22
  • \$\begingroup\$ I am posting it in my mobile app...it doesn't require a genius to find that button...thanx \$\endgroup\$ Dec 12, 2016 at 13:25
  • \$\begingroup\$ You jave a computer in front of you. People tend to answer questions with good images and text more. \$\endgroup\$
    – Bálint
    Dec 12, 2016 at 13:25
  • \$\begingroup\$ Oh..ok..then...i uploaded the pic to get a quick idea of what I am doing...I don't have time to tether my pc with my phone...everyone has their own Job..having pc infront of me doesn't compel me to use it for internet..it's my wish..anyways..thnks for your participation \$\endgroup\$ Dec 13, 2016 at 3:27
  • \$\begingroup\$ I didn't mean to insult you \$\endgroup\$ Dec 13, 2016 at 3:28

1 Answer 1


You need to know two things: 1) Where did the user click in your scene. 2) How did he move his mouse.

For 1) you need to cast a ray and check collisions to find out if and what "subcube" was clicked on. I am sure there's something like that in UE4.

2) is a little harder. You either want a horizontal or vertical slice of cubes to rotate. You could wait for a few milliseconds after the user clicked the left (?) mouse button and moved the mouse to check what direction he drags the mouse primarily. Then just dispose of the other value of the drag-vector and you have your movement vector. Input that in your rotation algorithm. There would be some input lag between clicking/dragging and the cubes moving, but I would not see how you can accurately determine the direction of the mouse drag otherwise.

What I find more intriguing is how you would find out what cubes to move. Do they each store their current neighbours or their absolute position in the main cube?

  • \$\begingroup\$ I figured out what set of cubes to move ..my problem is how do I translate mouse's x ,y coords to xyz screen space coordinates in unreal engine. Out of the box solutions would help me :( \$\endgroup\$ Dec 13, 2016 at 3:32
  • \$\begingroup\$ Do you mean how to translate the xy-screenspace coordinates of your mouse to the xyz-world space coordinates in the engine? The transformation over the different spaces is shown in every picking tutorial and there are plenty of those on the internet. I am not aware of additional options you might have with the unreal engine but if there is no picking mechanism provided, you can code it yourself. I would provide you with a link or two, but I cannot access most of those sites from my place, I am happy to be able to go on stackexchange.com.... Just google for "picking" and "raycasting"! \$\endgroup\$
    – Djindjidj
    Dec 13, 2016 at 9:29
  • \$\begingroup\$ Woopy ..done. confused with screen and world space coords \$\endgroup\$ Dec 13, 2016 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .