Home > Back-end >  UE4 rubik's cube game blueprint of logical problems
UE4 rubik's cube game blueprint of logical problems

Time:09-18

I recently is assuming made a rubik's cube UE4 little game, but stuck in part blueprint, say my train of thought and steps, first to the second order of the rubik's cube, for example,
1, first set up a Actor add eight cubes as the Angle of the second order rubik's cube blocks, each block first temporarily to a solid color material used for the difference between (regardless of the specific face) first and then put the eight Angle blocks set position, the following figure

2, add the two used to judge the rubik's cube corner piece of X, Y, Z position of cubes, put them respectively to get the right X, Y, Z coordinate position, the diagram below:

3, add 8 ball, the center of the sphere is zero, then respectively, will create the Angle of step 1 block is added to the eight ball child objects, make a sphere as a square in the center of rotation, the following figure

4, create a few buttons to control the direction of rotation, here, I only do the top surface and the right,
5, started writing logic, my idea is that used to make a good position to judge block and the coordinates of a rubik's cube block the coordinates of the comparison, if the X coordinate and reference block, X equal to the right, then according to the right of the clockwise or counterclockwise button, right rotation, with location estimation of Z coordinates and block compares the Z coordinate of rubik's cube, equal to top surface, accordingly, when clicking on the top surface clockwise or counterclockwise button, the top spin, specific attachment below
Figure 1: save the rubik's cube block position coordinates

Figure 2: to determine whether a rubik's cube blocks on the right side

Figure 3: click on the corresponding button to the right rotation

Has been achieved by this step right right rotation, the top surface also wrote logic, single click on the top surface also can correct the rotation of the
the problem comes
When the right rotation, and then click on the top surface rotates, and right across the top of the block does not follow the top spin, equally, should turn the top surface, and then turn right, crossing two piece does not follow the right turn, but looked at the junction, the coordinates of two pieces of Z coordinate is, indeed, and Z coordinates of the top are equal, but the judgment result is false, how to solve this, have been trapped for three days, the great spirit guide, what is wrong?
  • Related