can't tween value on script
« on: February 01, 2016, 09:46:10 PM »
HI

I have a camera FX script with a few public variables.
I call these from a different gameObject, and make a (working) connection as I can enable / disable the component. Thus knowing it has a good reference.

However. When I try to tween the float value 'intensity" on the script it does not tween.
other tweens in the same script does work.
for example a text tween: GM.ScoreText.DOText ("Score_" + GM.currentScore, 2f, false, ScrambleMode.None, null);

This tween however does not work.
Code: [Select]

WaterEffectScript WaterFX;
void Start(){
  WaterFX.enabled = false;
  WaterFX.Intensity = 0.66f;
  WaterFX = Camera.main.GetComponent<WaterEffectScript>();
}

public void OnTriggerEnter2D(Collider2D other){
 if (other.gameObject.tag == "Player") {
   WaterFX.enable = true; //works
   GM.ScoreText.DOText ("Score_" + GM.currentScore, 2f, false, ScrambleMode.None, null);//works
   DOTween.To (() => WaterFX.Intensity, x => WaterFX.Intensity = x, 0,2f).OnComplete(DisableFX); //doesn't tween
  }
}


Thanks for your insight.



*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: can't tween value on script
« Reply #1 on: February 01, 2016, 09:50:34 PM »
Hi!

Your code seems absolutely legit, so the only reason that property might not be tweened should be one of these:
1) You're resetting it every frame somewhere
2) You're resetting the tween every frame somewhere
3) Something else is controlling the Intensity value

Let me know, and cheers,
Daniele

Re: can't tween value on script
« Reply #2 on: February 02, 2016, 12:43:43 PM »
Thanks Daniele.

So far I haven't been able to figure it out.
Alas I don't have the time to examine this further, but when I can i'll post my findings here (regardless if they are embarrassing or not) :)

All the best

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: can't tween value on script
« Reply #3 on: February 03, 2016, 01:13:26 PM »
Aha thanks! :)