dotween
dotween copied to clipboard
DOShakeRotation not working on Z axis with randomness = 0
It seems that DOShakeRotation
is not working on the Z axis when setting the parameter strength
to a Vector3
and randomness
to 0. This is an example that isn't working:
transform.DOShakeRotation(1, new Vector3(0, 0, 90), randomness:0).SetLoops(-1);
However, any of these work:
transform.DOShakeRotation(1, new Vector3(0, 0, 90), randomness:90).SetLoops(-1);
transform.DOShakeRotation(1, new Vector3(0, 90, 0), randomness:0).SetLoops(-1);
DoTween version: 1.1.555, Unity version: 5.5.0f3 (64bit)
Actually, when setting strength
to a float, it also doesn't affect the Z axis, only X and Y, for example:
transform.DOShakeRotation(1, 90, randomness:0).SetLoops(-1);
up
I'm also confused by this. I have a 2D bottle I want to shake (strength = Vector3(0, 0 , shakeAmount)
), but I'm not sure this function is really designed for this.
applying a randomness
value seems to cause jumps in the animation (rather than modifying the /end position etc for each shake), and setting a 0 value causes it to do nothing.
essentially I am trying to shake the bottle between eg -30 and 30 degrees, with a slight randomness so it has some variation.
any advice welcome thanks
Same problem here
I just wasted the last hour debugging random stuff only to find out that the Z axis on DOShakePosition
does jackshit! X and Y work perfectly, but Z is busted, since it only works if you modify the randomness. I don't really want randomness on my shake... @Demigiant this needs fixing.
Sorry guys for the late reply, but I think there's some confusion on what shake means. Shake is a rather complex thing, but it's mostly based on randomness (even if there's a randomness parameter), contrary to punch which has a linear decay. Shaking on a single axis requires the randomness value to be set to 90, as the docs say, and I admit it's not a really nice effect because Shake is more a 3D (or at least 2.5D) effect. If you want to shake on a single axis without any randomness then you're looking for a punch, not a shake, and thus DOPunchRotation.
@Demigiant If this is how the effect is suppossed to work, it's highly confusing, are you sure there's not a bug? For example:
transform.DOShakeRotation(1, new Vector3(0, 0, 50), randomness:0).SetLoops(-1); // This doesn't make the object rotate, as indicated
transform.DOShakeRotation(1, new Vector3(0, 50, 0), randomness:0).SetLoops(-1); // This makes the object rotate on the Y axis, even with "randomness" being 0
transform.DOShakeRotation(1, 50, randomness:0).SetLoops(-1); // This makes the object rotate on the X and Y axes, but not Z
Shouldn't the second line not make the object rotate since the randomness is 0, like the first line? And shouldn't the third line make the object rotate on Z (the randomness is 0, but we are not rotating on a single axis)? You mention it being a 2.5D effect, which I guess may be a clue, but I still don't really get what is going on. Why not Z?
Some strange solution of this
DOTween.Shake(() => transform.rotation.eulerAngles, x =>
{
var rotation = transform.rotation;
rotation.eulerAngles = Vector3.forward * x.x;
transform.rotation = rotation;
}, 1, 10, 8, 0);
same here
Some strange solution of this
DOTween.Shake(() => transform.rotation.eulerAngles, x => { var rotation = transform.rotation; rotation.eulerAngles = Vector3.forward * x.x; transform.rotation = rotation; }, 1, 10, 8, 0);
Problem solved, amazing!
I was confused at first to, because I misinterpreted the documentation. For a simple ShakeRotation around the Z axis that takes 1 second and rotates by max 45° use:
transform.DOShakeRotation(1, Vector3.forward * 45);
If you use a Vector3 as a parameter, you don't give a direction but a Vector3 of strenghts for each axis. So Vector3(0, 0, 45) means: Rotate max 0 degrees around X, max 0 degrees around Y and max 45 degrees around Z,
If you use float as a parameter, this value is used for all axes.
Works well. DOTween is great, thank you for making it.