*

BitBash

DoTween on a Vector3
« on: August 15, 2015, 04:58:25 PM »
Hi,

Quick question please. Looking through the documentation, I have not seen a method to Tween my own variable. For example:

public Vector3 customVector;

Is there something I am missing? Sorry if it's a stupid question, I really have looked.

Thanks!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DoTween on a Vector3
« Reply #1 on: August 15, 2015, 06:34:48 PM »
Hi,

All DOTween shortcuts are made for known Unity variables, but they all take advantage of the generic tweening way in the background. Said generic tweening way is what you want to use when tweening custom variables. In your case, here's an example:
Code: [Select]
// Tween customVector to 3,4,2 in 2 seconds
DOTween.To(()=> customVector, x=> customVector = x, new Vector3(3,4,2), 2);

Cheers,
Daniele

*

BitBash

Re: DoTween on a Vector3
« Reply #2 on: August 15, 2015, 07:57:52 PM »
Amazing! Thanks Daniele.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DoTween on a Vector3
« Reply #3 on: August 15, 2015, 08:00:00 PM »
You're welcome :)