Demigiant Forum
Unity Assets => DOTween & DOTween Pro => Topic started by: Thenamelessone on August 25, 2015, 01:16:22 AM
-
I am trying to tween the image effect: Chromatic Aberration in a sequence.
sequence.AppendDOVirtual.Float(0, aberrationRange, tweenDuration, UpdateTween);
sequence.Append(DOVirtual.Float(aberrationRange, -aberrationRange, tweenDuration, UpdateTween));
sequence.Append(DOVirtual.Float(-aberrationRange, 0, tweenDuration, UpdateTween));
private void UpdateTween(float value)
{
imageEffect.chromaticAberration = value;
}
The sequence doesn't play. I cannot figure out how to do this :(
Thanks!
(I love your asset! I can't wait to buy the pro when I have enough money :)
-
Hi,
I'm very glad you like DOTween :)
Virtual tweens can't be appended to Sequences. My bad for not pointing it out in the docs (just updated them to say it). Also because there's a much better way to do what you want, using the generic way (http://dotween.demigiant.com/documentation.php#genericTo), which won't even need the UpdateTween method nor the extra aberrationRange variable, since it can tween imageEffect.chromaticAberration directly:
// Important: in this case you'll have to set the starting value directly before starting the tween
imageEffect.chromaticAberration = 0;
sequence.Append(DOTween.To(()=>imageEffect.chromaticAberration, x=> imageEffect.chromaticAberration = x, aberrationRange, tweenDuration));
sequence.Append(DOTween.To(()=>imageEffect.chromaticAberration, x=> imageEffect.chromaticAberration = x, -aberrationRange, tweenDuration));
sequence.Append(DOTween.To(()=>imageEffect.chromaticAberration, x=> imageEffect.chromaticAberration = x, 0, tweenDuration));
Cheers,
Daniele
-
For some reason that doesn't work. I don't get any errors, it just doesn't play :(
Is there a piece that is missing?
Here is a SS of the script. https://www.dropbox.com/s/dng8lypy4brylwo/Screenshot%202015-08-25%2010.41.23.png?dl=0 (https://www.dropbox.com/s/dng8lypy4brylwo/Screenshot%202015-08-25%2010.41.23.png?dl=0)
-
Did you debug? Try to use parameters instead of variables
-
You are not creating the Sequence anywhere, via
sequence = DOTween.Sequence();
-
Thanks everyone! I feel like a complete idiot for missing that... :-\
-
Nono, I should implement some warning when you forget to initialize a Sequence. Added it to my todo list ;)