Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - simonj

Pages: [1]
1
DOTween & DOTween Pro / get Path in callback function
« on: August 14, 2015, 09:19:38 AM »
Hi.

I'm trying to work out how to access the Path once I have used a callback function. The new function won't have scope of the Tween created so I'd like to know how to access it. I would like to be able to set a waypoint dynamically to give a random look using the gotowaypoint function but obviously need a handle on the Tween first.

Your help is appreciated.


// taken from the supplied sample code

using UnityEngine;
using System.Collections;
using DG.Tweening;

public class Paths : MonoBehaviour
{
   public Transform target;
   public PathType pathType = PathType.CatmullRom;

   Vector3[] waypoints = new[] {
      new Vector3(-3.48f,-6.358611f,0f),
      new Vector3(-3.02f,-6.14f,0f),
      new Vector3(-2.348492f,-6.003549f,0f),
      new Vector3(-1.919789f,-5.918438f,0f),
      new Vector3(-1.533964f,-5.918437f,0f),
      new Vector3(-1.276615f,-5.807039f,0f),
      new Vector3(-0.7315713f,-5.847458f,0f),
      new Vector3(-0.2636646f,-5.965012f,0f),
      new Vector3(0.2385418f,-6.102207f,0f),
      new Vector3(0.5094132f,-6.184325f,0f),
      new Vector3(0.8023798f,-6.183298f,0f)
   };

void Start()
   {

      Tween t = target.DOPath(waypoints, 4, pathType)
         .SetOptions(true)
         .SetLookAt(0.001f)
         .SetId("supertween")
         .OnWaypointChange(MyCallback);
             t.SetEase(Ease.Linear).SetLoops(-1);
   }

void MyCallback(int a) {
 // how to access the Tween/Path in this function?
}

Pages: [1]