Rotating mesh around Y-Axis pass 90 degrees

Hi:

I am working on a simple blueprint, basically a Rubiks Cube in 27 pieces. I have setup a collision inside the blueprint to pick up all the overlapping pieces and rotate them around the central point.

The blueprint works for any rotations X-Axis and Z-Axis. but when it comes to Y-Axis the rotation does not go pass 90 degrees, and the cubes glitches (shaking in place). I have then wrote a simple “add to relative location” blueprint for a single cube rotating, and the same issue persists, X and Z Axis are fine but won’t rotate pass 90 on Y.

Is this some fundamental issue with rotating around Y-Axis in blueprint? I don’t know C++ so I would like to have it resolved in blueprint if possible. I am also using foreachloop for the rubiks Cube blueprint so I prefer to use a event tick or timer. timeline doesn’t seem to work with foreachloop.

Thanks.

Regards
Kuan

Hey, could you post a screenshot of the BP editor viewport to see how your components are set up?

Hi:

Here are the blueprints. First two are the Rubiks Cube, the third one is the simple add relative location setup I used to test whether the basic concept of rotating around Y-Axis can work or not.

In the first setup (first two screenshot) you have nothing going in “enter” in the gate node. I think execution must go through “enter” in order to “exit”, open and close are only there to open or close it. However, this does not explain why your second setup produces the same result so this cannot be the cause.

Yes ForEachLoop does not work with any time related nodes (e.g. delay, etc.). You can create your own version, e.g. I have one with delay.

Could you post a screenshot of how your 27 cube components are parented to the root or other component or the collision? Add relative rotation is always relative to the immediate parent. Are you perhaps transforming the parent component at the same time resulting in the fact that it never gets past 90 degrees?

Do you have any logic in the construction script? When does the problem occur? In the editor, too, or only when playing?

You know what… I just tested and it in a new map and it seems that Y is always between -90 and 90.

It seems to be a known issue or intended functionality:

There are some mentions of workarounds there…

Thanks. I must have forgot to plug in the enter when I was trying to fix the blueprint, but definitely the blueprint is working when it was on x-axis and z-axis. It is strange that Y-axis does not function the same way.

I tried to use add local location but that didn’t work. I will keep trying to look for a solution…

Actually I just tried again and addlocationrotation seem to have worked. Now I have a another issue: I am using event tick and because my computer gives me unstable frame rate (dip from 120 to 20), everytime I rotate 90 degrees I seem to get a slightly different rotation angle. Is there a way to fix that? Thanks.

Great! So it is now giving you past 90 values?

Yes. You can set the actor tick interval in the details tab in the BP editor. You could set to higher value so according to the largest time in ms between your frames.

Or you can use delta seconds from event tick and add in some math to convert it to frame-rate independent time.

Hi:

Thanks. I tried get delta time, multiply delta by 90 degree angle (time to rotate 90 degree is 1 second), then set that as variable to plug into my rotation angles. It still gives me a tiny tiny discrepancy - about 0.08-0.1 degree-ish. I think this is due to my framerate not being locked. I tried setting actor tick to higher milli-seconds which is fine if framerate is consistent, but as soon as it dips I will get an small degree error. Since my blueprint is a rubiks cube, when I rotate other rows this discrepancy will be carried into other rows.

Is there a framerate independent way in foreachloop to rotate an array of objects? I might try timeline but I don’t know how to use timeline with foreachloop and rotate.

Thank you.

hmm, I do believe that if you put a high enough tick interval (one that is definetely larger than the biggest lag you get) it should solve the problem. But then it might make your game choppy.

How about you round the output rotation to the nearest integer before you plug it back in?

That’s great advise. I will do that I think. Thank you.

BTW is there a way for timeline to work with foreachloop and rotate around axis? I heard timeline is fps independent.

You want a timeline to be started for each array element? I think it won’t work because of the way loop nodes work in general. Why do you need a timeline?

Hey, have you checked what is your bottleneck? If it is the game thread, then some code makes your system hang . How many elements do you have in your array? Are implementing something with time or delay in your looping code?

It works great in first person mode, I am able to keep fps above 60. Even when the fps drops as long as it is not a huge drop all of a sudden the rounding can correct it. However when I take it to VR mode (this scene is simple with just one blueprint), the framerate becomes very unpredictable and can fluctuate hugely (starts off with 60 and dips to 20 sometimes). It gives me up to 30 degrees of error sometimes and my round up doesn’t seem to be able to correct it.

Sorry I am not much of an expert so I am not sure how to check the thread. The blueprint is a rubiks cube and I constructed collision box to get all small cubes in a single turning direction, so each time the collision will be picking up 9 mesh as well as the other 7 collision boxes, then I run it through a loop to get rid of all the collision boxes then rotate around an axis. I tried set timer before but it seems to be the same, quite frame depended.

Typ in console command “stat unit”. Then you see which of the three thread is causing your framerate drop. (the highest ms value at any given time) if it is the game thread, then it is something in your code.