Simultaneous tweening of separate axes' rotation
« on: August 07, 2015, 03:47:57 PM »
Hi! Just wondering if I'm correct in this assumption. In the following scenario the second tween would override the first.

Code: [Select]
obj.DORotate(Vector3.up, 0.5F);
obj.DORotate(Vector3.right, 1);

To clarify, tween #1 goes to (0,1,0) and #2 to (1,0,0). The second tween re-specifies the Y component of the first tween as 0, effectively overriding #1's Y value of 1.

It'd be handy to be able to do these compound rotations at different speeds, although I can see how that might get tricky in terms of setting the Euler angles or Quaternion values. Can't do them for a single axis.

Or maybe I'm not understanding the correct way to make this work simultaneously. Sequences? SetRelative? DOvoodooMagicTween?

Thank you kindly! I love DOTween to bits.
« Last Edit: August 08, 2015, 10:38:36 AM by editkid »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Simultaneous tweening of separate axes
« Reply #1 on: August 07, 2015, 06:11:23 PM »
Hi!


Tweens targeting the same property on the same target indeed overwrite each other. I create special methods for position (DOMoveX/Y/Z) which work independently, but for rotation that can't really be done (because Quaternions are the mother of all necessary evils).


The only trick you could use, would be to have a parent/child relationship, where you rotate the parent in one direction and the child in another. In that case, with two different targets, that would work.


Cheers,
Daniele

Re: Simultaneous tweening of separate axes
« Reply #2 on: August 08, 2015, 10:37:46 AM »
Thanks! As I suspected. I'm probably missing something, and apologies for the crude example, but would it be possible to do the following? If you wanted to do a hypothetical DORotateY.

Code: [Select]
Vector3 v = transform.rotation.eulerAngles;
transform.rotation = Quaternion.Euler (v.x, value, v.z);

Cheers,
Peter
« Last Edit: August 08, 2015, 10:41:39 AM by editkid »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Simultaneous tweening of separate axes' rotation
« Reply #3 on: August 08, 2015, 11:16:45 PM »
I do exactly that with position/scale X/Y/Z tweens. But in case of Quaternions that would mess things up, because vectors are not so straightly converted into Quaternions.


Cheers,
Daniele

Re: Simultaneous tweening of separate axes' rotation
« Reply #4 on: August 09, 2015, 12:12:20 AM »
Ah yes, of course. Thank you!  :)