changed the flight of the bird to be able to have more control over the takeoff, loops and landing.
58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using Pixelplacement;
|
|
using UnityEngine;
|
|
|
|
public class soundBird_Spooked_FlyBehaviour : MonoBehaviour
|
|
{
|
|
public Spline FlightSpline;
|
|
public Transform SoundBirdObject;
|
|
public float flightDuration;
|
|
public float flightDelay;
|
|
[Range(0, 1)] public float startPercentage;
|
|
|
|
private StateMachine stateMachine;
|
|
private Animator animator;
|
|
[SerializeField] private State stateRef;
|
|
|
|
void Awake()
|
|
{
|
|
stateMachine = GetComponentInParent<StateMachine>();
|
|
animator = GetComponentInParent<Animator>();
|
|
stateRef = GetComponent<State>();
|
|
}
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
//initiateTweenSpline();
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
Tween.Spline(FlightSpline, SoundBirdObject, 0, 1, false, flightDuration, flightDelay, Tween.EaseLinear, Tween.LoopType.None, HandleTweenStarted, HandleTweenFinished);
|
|
}
|
|
|
|
void HandleTweenStarted()
|
|
{
|
|
|
|
}
|
|
void HandleTweenFinished()
|
|
{
|
|
if (SoundBirdObject != null)
|
|
{
|
|
//Tween.Stop(SoundBirdObject.GetInstanceID(), Tween.TweenType.Spline); // Stop the spline tween for this object
|
|
}
|
|
//Debug.Log("Tween finished!");
|
|
if (stateMachine != null)
|
|
{
|
|
//stateMachine.ChangeState("SoundBird"); // Change to the desired state name
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|