-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Rotated cards flipping problem #133
Comments
The flip when rotated I think is expected, since it still stays in the correct orientation, but the sides have been flipped. However, the rotation changing completely when flipping it rapidly is definetly a bug. |
They do flip yes, but the animation looks weird. I still think this is a bug - the rotation seems to be done around the wrong axis / in the wrong coordinate system. If the card would flip the same as it does with the default orientation, then there would be no issue with flipping rapidly (since this issue is also only on rotated cards). They should flip like this (I rotated the camera): Not like this (I rotated the object): You can see that in the second video the card makes two rotations - one back to the original orientation and the flipping simultaneously (and back). |
So if I didn't took a wrong turn, I narrowed down the problem to The hover state is applied to reach the target state from the current state. However, the angular_velocity is calculated from the difference of the current and target state. I think this is the issue. When an rotated objected is flipped, the angular_velocity is != 0 in all 3 axis. This is why the flipping occurs differently even on the same rotation. What should be done: Therefore the Piece would need to know if it is currently being rotated or flipped to apply the velocity to the correct axis. Does that sound right? |
The way I programmed that function to work was to account for all possible "rotations", and ideally I would like that to still be the case, without using any outside variables. Maybe there's a way to modify the rotation so it's "nicer" within the function by checking the current and target rotation? By the way, I'll put the relevant code here for convenience:
|
I don't think this would work. Let's take a look at two rotations:
Based on these two values only, how do you want to decided in which direction you want to rotate? Positive direction, negative direction? Which axis? You can't. You will take the shortest way. So theoretically you don't want to take the shortest rotation - you want to rotate around a specific axis only. This information cannot be obtained from what the function currently knows. You can keep the function for normal rotations. But in case of a flip you will need a specific function to handle this animation/rotation which knows that it should only rotate in the positive Z direction. Or extending the current one with this information. The flip should always be in the same direction, around the same axis. At least I don't see how this would work if we only know these 2 rotations. Maybe someone can enlighten me 😄 Also we should maybe use quaternions to avoid the euler shortcomings. |
Surely we can tell if the object has been flipped by looking at the rotations? Flipping the object rotates it by 180 degrees in the Z (back/front) axis, so that means both the X (left/right) and Y (up/down) axis flip to the other side. If we can check that's what happened, then surely we can at least get the rotation started in the right direction? With regards to the quaternions, I do agree, but it'll take some time to switch from using Basis to Quat for that system - I'll probably get started on that today, as it would also optimise bandwidth usage. |
Sure you can do that, but wouldn't that just be a hacky workaround? Guessing if this is a flip? If you try such a guess work, why not use a variable to indicate that this is a flip - get it started in the right direction and then you can set back the flip variable to false. More secure, less guess work. Would it be that bad to have an outside variable for this? Of course guessing should work but I think it would be safer and - most of all - cleaner to use a variable indicating a flip has started? Maybe the quaternion will actually already fix something here. I'm still not sure why this jittering happens sometimes when flipping. |
Personally I think it's better if we keep the I do agree Quaternions in this situation sound promising, and they also have several functions for lerping to another rotation (which may solve the root problem we have). |
Okay, I managed to fix the issue using
I'll do some extra tweaking and optimisation before pushing the changes. I'll also make a separate issue for using quaternions, since I still think that should be done at some point. Here are the results: test.mp4 |
Looks good. I was afraid that the angular_velocity is the culprit but didn't know you are willing to ditch it 😄 Glad that it's a very simple fix. |
I'm going to miss letting go of cards mid-way through flipping them and seeing them catapult into space 😢 |
Well while it is a cool thing to do, it's not so cool when you are actually trying to play a boardgame 😄 even less so when it goes off knocking over all your other boardgame pieces The |
Describe the bug
Rotated cards look weird when flipped. It seems they try to flip on the world axis instead of it's current orientation.
Also, if you continue to press the F key rapidly, it gets completely messed up. Probably because of the incorrect flipping described above.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The card should flip around it's own axis, a normal flip to the right
Screenshots
rotate_1.webm
rotate_2.webm
Version
v0.1.0 Beta 1
The text was updated successfully, but these errors were encountered: