- Home /
Question by
DavidKlecker · Mar 12, 2021 at 10:40 PM ·
unity 2ditweenputonpath
iTween PutOnPath Object does not move
I have the following code to move my object along a path i have created.
void Update()
{
Transform[] x = new Transform[3];
x[0] = sa.GetWayPoints()[0];
x[1] = sa.GetWayPoints()[1];
x[2] = sa.GetWayPoints()[2];
sa.currentPathPercent += sa.percentsPerSecond * Time.deltaTime;
iTween.PutOnPath(sa.EnemyPrefab, x, sa.currentPathPercent);
}
Update is in my gameObject I want to move.
sa is a scriptable object that contains my path and my enemy and the percentage speed and currentPathPercent.
public class SimpleAnimation : ScriptableObject
{
public GameObject waypointArray;
public GameObject EnemyPrefab;
public float percentsPerSecond = .02f; // %2 of the path moved per second
public float currentPathPercent = 0.0f; //min 0, max 1
public Transform[] GetWayPoints()
{
List<Transform> wayPoints = new List<Transform>();
foreach(Transform child in waypointArray.transform)
{
wayPoints.Add(child);
}
return wayPoints.ToArray();
}
}
I have tested the points to see if they do represent correct points. My object will not move. I have no idea what is wrong.
Comment