using UnityEngine; using Pixelplacement; using Pixelplacement.TweenSystem; public class GardenerChaseBehavior : MonoBehaviour { public Spline ChaseSpline; public Transform GardenerObject; public float chaseDuration; public float chaseDelay; [SerializeField] private Animator animator; [SerializeField] public GameObject lawnMowerRef; private TweenBase tweenRef; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { tweenRef = Tween.Spline (ChaseSpline, GardenerObject, 0, 1, false, chaseDuration, chaseDelay, Tween.EaseLinear, Tween.LoopType.None, HandleTweenStarted, HandleTweenFinished); } void HandleTweenFinished () { //Debug.Log ("Tween finished!"); tweenRef.Stop(); Destroy(ChaseSpline); var gardenerSpriteRef = gameObject.transform.Find("GardenerRunningSprite"); gardenerSpriteRef.transform.SetParent(lawnMowerRef.transform, true); } void HandleTweenStarted () { //Debug.Log ("Tween started!"); animator.SetBool("IsIdle?", false); } }