Virtual Float
« on: August 25, 2015, 01:16:22 AM »
I am trying to tween the image effect: Chromatic Aberration in a sequence.

Code: [Select]
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 :)

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Virtual Float
« Reply #1 on: August 25, 2015, 02:10:20 PM »
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, which won't even need the UpdateTween method nor the extra aberrationRange variable, since it can tween imageEffect.chromaticAberration directly:

Code: [Select]
// 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

Re: Virtual Float
« Reply #2 on: August 25, 2015, 04:40:34 PM »
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

*

abe

  • ***
  • 11
    • View Profile
Re: Virtual Float
« Reply #3 on: August 25, 2015, 06:25:28 PM »
Did you debug? Try to use parameters instead of variables

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Virtual Float
« Reply #4 on: August 25, 2015, 06:40:05 PM »
You are not creating the Sequence anywhere, via

Code: [Select]
sequence = DOTween.Sequence();

Re: Virtual Float
« Reply #5 on: August 25, 2015, 06:49:45 PM »
Thanks everyone! I feel like a complete idiot for missing that... :-\

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Virtual Float
« Reply #6 on: August 25, 2015, 06:54:18 PM »
Nono, I should implement some warning when you forget to initialize a Sequence. Added it to my todo list ;)