x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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

Product Version: UE 4.18
Tags:
more ▼

asked Apr 13 '18 at 04:28 AM in Blueprint Scripting

avatar image

flight64au
1 1 2 1

avatar image BreakMaker Apr 13 '18 at 06:41 AM

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

avatar image flight64au Apr 13 '18 at 06:50 AM

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.

box1.jpg (113.8 kB)
box2.jpg (114.1 kB)
box3.jpg (90.8 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

4 answers: sort voted first

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?

more ▼

answered Apr 13 '18 at 08:01 AM

avatar image

BreakMaker
232 4 11 15

avatar image BreakMaker Apr 13 '18 at 08:12 AM

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: https://answers.unrealengine.com/questions/81372/bug-actor-relative-pitch-rotation-stuck-in-90-degr.html?sort=oldest

There are some mentions of workarounds there...

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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...

more ▼

answered Apr 13 '18 at 10:42 AM

avatar image

flight64au
1 1 2 1

avatar image flight64au Apr 13 '18 at 12:04 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 13 '18 at 12:09 PM

avatar image

BreakMaker
232 4 11 15

avatar image flight64au Apr 13 '18 at 12:26 PM

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.

avatar image BreakMaker Apr 13 '18 at 12:43 PM

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?

avatar image flight64au Apr 14 '18 at 12:47 AM

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.

avatar image BreakMaker Apr 15 '18 at 03:45 PM

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?

avatar image flight64au Apr 16 '18 at 06:30 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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?

more ▼

answered Apr 16 '18 at 07:21 AM

avatar image

BreakMaker
232 4 11 15

avatar image flight64au Apr 16 '18 at 10:23 AM

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.

avatar image BreakMaker Apr 16 '18 at 12:39 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question