Files
AppleHillsProduction/Assets/Scripts/DamianExperiments/ButterFlyBehaviour.cs

54 lines
1.3 KiB
C#
Raw Normal View History

2025-11-12 16:25:32 +01:00
using Pixelplacement;
using UnityEngine;
using Core.SaveLoad;
public class ButterFlyBehaviour : MonoBehaviour
{
public AppleMachine butterStateMachine;
2025-11-12 16:25:32 +01:00
public Spline butterflightSpline;
public Transform butterflyObject;
public float flightDuration = 2f;
public float flightDelay = 0f;
private const float AnchorThreshold = 0.05f;
private Animator butterflyAnimator;
2025-11-12 16:25:32 +01:00
// Called when entering the butterfly flight state
public void OnEnable()
2025-11-12 16:25:32 +01:00
{
if (butterflightSpline == null || butterflyObject == null)
{
Debug.LogWarning("ButterFlyBehaviour: Missing spline or butterfly object reference.");
return;
}
if (butterflyObject != null )
2025-11-12 16:25:32 +01:00
{
butterflyAnimator = butterflyObject.GetComponentInChildren<Animator>();
2025-11-12 16:25:32 +01:00
}
butterflyAnimator.SetTrigger("BrokeOut");
2025-11-12 16:25:32 +01:00
Tween.Spline(
butterflightSpline,
butterflyObject,
0,
1,
2025-11-12 16:25:32 +01:00
false,
flightDuration,
2025-11-12 16:25:32 +01:00
flightDelay,
Tween.EaseInOut,
Tween.LoopType.None, HandleTweenStarted, HandleTweenFinished
2025-11-12 16:25:32 +01:00
);
}
public void HandleTweenStarted()
{
}
public void HandleTweenFinished()
{
butterStateMachine.ChangeState("Free");
}
2025-11-12 16:25:32 +01:00
}