Redid the SoundBird Logic of flight
changed the flight of the bird to be able to have more control over the takeoff, loops and landing.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
|
||||
public class soundBird_TakeOffBehaviour : MonoBehaviour
|
||||
{
|
||||
public Spline FlightSpline;
|
||||
public Transform SoundBirdObject;
|
||||
public float flightDuration;
|
||||
public float flightDelay;
|
||||
private StateMachine stateMachine;
|
||||
private Animator animator;
|
||||
private TweenBase objectTween;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
stateMachine = GetComponentInParent<StateMachine>();
|
||||
animator = GetComponentInParent<Animator>();
|
||||
}
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
//initiateTweenSpline();
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
animator.SetBool("isScared", true);
|
||||
objectTween = Tween.Spline(FlightSpline, SoundBirdObject, 0, 1, false, flightDuration, flightDelay, Tween.EaseLinear, Tween.LoopType.None, HandleTweenStarted, HandleTweenFinished);
|
||||
}
|
||||
void HandleTweenStarted()
|
||||
{
|
||||
|
||||
}
|
||||
void HandleTweenFinished()
|
||||
{
|
||||
if (SoundBirdObject != null)
|
||||
{
|
||||
objectTween.Cancel(); // Stop the spline tween for this object
|
||||
|
||||
}
|
||||
//Debug.Log("Tween finished!");
|
||||
if (stateMachine != null)
|
||||
{
|
||||
stateMachine.ChangeState("SoundBirdFlyAround"); // Change to the desired state name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user