Tweening to a certain waypoint in a Path Tween
« on: March 27, 2016, 08:04:30 PM »
Hi,

Is it possible to tween an object to a certain waypoint path.
In other words, assume I have a path with 10 waypoints, can I tween an object to waypoint 5 and then continue the tween after a certain event ?

Thanks

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tweening to a certain waypoint in a Path Tween
« Reply #1 on: March 28, 2016, 01:08:48 AM »
Hi,

You can use the OnWaypointChange callback to know when a waypoint changes, and react accordingly. If you're using a DOTweenPath and not a scripted one, you will first have to grab a reference to the tween itself, and than apply the callback, like this:

Code: [Select]
myDOTweenPath.GetTween().OnWaypointChange(myCallback);

Cheers,
Daniele
« Last Edit: March 28, 2016, 01:10:30 AM by Daniele »

Re: Tweening to a certain waypoint in a Path Tween
« Reply #2 on: March 28, 2016, 08:14:28 AM »
I am not quite sure I understand but how do I tell the object to tween to a certain n the waypoint path drawn via the editor.

Please check attached image for a better representation..

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tweening to a certain waypoint in a Path Tween
« Reply #3 on: March 30, 2016, 02:44:59 AM »
For example you would do this:

Code: [Select]
Tween myPathTween;

void Start()
{
   // Get tween from DOTweenPath and attach callback
   myPathTween = this.GetComponent<DOTweenPath>().GetTween();
   myPathTween.OnWaypointChange(WPCallback);
}

void WPCallback(int waypointIndex)
{
   if (waypointIndex == 3) myPathTween.Pause();
}

// Call this method when you're ready to resume the tween
void ResumeTween()
{
   myPathTween.Play();
}

Re: Tweening to a certain waypoint in a Path Tween
« Reply #4 on: March 30, 2016, 08:17:31 AM »
Thanks Daniele that was extremely helpful  :)

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tweening to a certain waypoint in a Path Tween
« Reply #5 on: March 30, 2016, 12:03:55 PM »
:)

Re: Tweening to a certain waypoint in a Path Tween
« Reply #6 on: April 15, 2016, 06:59:52 PM »
Hi Daniele!

I was also looking for a way to tween to a certain waypoint. However I also need easing to properly work for that section of the path.
I'm creating a long path made of several sections. I need the camera to smoothly move to a certain point, stop there waiting for an event, and then continue moving to the next point, etc.

What would be the best way to achieve this?

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tweening to a certain waypoint in a Path Tween
« Reply #7 on: April 16, 2016, 01:33:05 AM »
Hey Devil!

I replied on Unity's forums already, but I will add something here. You can also use the OnWaypointChange callback to pause your tween at a given waypoint, but that will not adapt the ease to it. Meaning that, if you have an OutQuart ease, you won't have the full smoothness at the end of it until you reach the last waypoint.

Cheers!
Daniele