Fixed SoundBird Bug
This commit is contained in:
@@ -11,6 +11,7 @@ public class cameraSwitcher : MonoBehaviour
|
||||
[SerializeField] private float normalOrthoSize = 20f;
|
||||
[SerializeField] private float transitionDuration = 0.5f; // Duration of the transition
|
||||
[SerializeField] private soundBird_FlyingBehaviour flyingBehaviour;
|
||||
[SerializeField] private soundBird_TakeOffBehaviour takeOffBehaviour; // New reference
|
||||
[SerializeField] private StateMachine birdStateMachine;
|
||||
|
||||
private int playerInsideCount = 0;
|
||||
@@ -38,12 +39,16 @@ public class cameraSwitcher : MonoBehaviour
|
||||
{
|
||||
if (zoomCoroutine != null) StopCoroutine(zoomCoroutine);
|
||||
zoomCoroutine = StartCoroutine(SmoothOrthoSize(virtualCamera, normalOrthoSize, transitionDuration));
|
||||
// Fix: Check if currentState's name is "SoundBirdFlyAround" and flyingBehaviour is not null
|
||||
if (birdStateMachine.currentState != null &&
|
||||
birdStateMachine.currentState.name == "SoundBirdFlyAround" &&
|
||||
flyingBehaviour != null)
|
||||
if (birdStateMachine.currentState != null)
|
||||
{
|
||||
flyingBehaviour.StartLanding();
|
||||
if (birdStateMachine.currentState.name == "SoundBirdFlyAround" && flyingBehaviour != null)
|
||||
{
|
||||
flyingBehaviour.StartLanding();
|
||||
}
|
||||
else if (birdStateMachine.currentState.name == "SoundBirdTakeoff" && takeOffBehaviour != null)
|
||||
{
|
||||
takeOffBehaviour.StartLanding();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class soundBird_TakeOffBehaviour : MonoBehaviour
|
||||
private StateMachine stateMachine;
|
||||
private Animator animator;
|
||||
private TweenBase objectTween;
|
||||
public soundBird_FlyingBehaviour flyingBehaviour;
|
||||
|
||||
public AppleAudioSource audioSource;
|
||||
|
||||
@@ -48,4 +49,19 @@ public class soundBird_TakeOffBehaviour : MonoBehaviour
|
||||
stateMachine.ChangeState("SoundBirdFlyAround"); // Change to the desired state name
|
||||
}
|
||||
}
|
||||
|
||||
// Added for cameraSwitcher
|
||||
public void StartLanding()
|
||||
{
|
||||
if (objectTween != null)
|
||||
{
|
||||
objectTween.Cancel();
|
||||
}
|
||||
if (stateMachine != null)
|
||||
{
|
||||
flyingBehaviour.midFlightPosition = SoundBirdObject.position;
|
||||
stateMachine.ChangeState("SoundBirdLanding");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user