Files
AppleHillsProduction/Assets/Scripts/Animation/GardenerChaseBehavior.cs

51 lines
1.2 KiB
C#
Raw Normal View History

2025-09-10 22:17:51 +02:00
using UnityEngine;
using Pixelplacement;
using Pixelplacement.TweenSystem;
2025-09-10 22:17:51 +02:00
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;
2025-09-10 22:17:51 +02:00
// 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);
2025-09-10 22:17:51 +02:00
}
void Awake()
{
}
// Update is called once per frame
void Update()
{
}
2025-09-10 22:17:51 +02:00
}