// Update is called once per frame void FixedUpdate() { distance += Time.fixedDeltaTime * speed; var path = PathToFollow.GetComponent <FFPath>(); if (path) { var PrevPos = path.PointAlongPath(distance - 0.01f); var position = path.PointAlongPath(distance); var vecForward = Vector3.Normalize(position - PrevPos); transform.position = position; transform.up = vecForward; if ((int)(distance / path.PathLength) > loopCounter) { loopCounter = (int)(distance / path.PathLength); PathFollowerCompletedLoopEvent e; e.distTraveled = path.PathLength; e.obj = gameObject; FFMessage <PathFollowerCompletedLoopEvent> .SendToLocal(e); } } }
// Update is called once per frame void FixedUpdate() { distance += Time.fixedDeltaTime * speed; var path = PathToFollow.GetComponent <FFPath>(); if (path) { var position = path.PointAlongPath(distance); transform.position = position; if ((int)(distance % path.PathLength) > loopCounter) { loopCounter = (int)(distance % path.PathLength); PathFollowerCompletedLoopEvent e; e.distTraveled = path.PathLength; FFMessage <PathFollowerCompletedLoopEvent> .SendToLocal(e); } } }