apple-picker/Assets/Scripts/Apple.cs
2024-02-08 19:15:28 -06:00

29 lines
817 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Apple : MonoBehaviour
{
[Header("Set in Inspector")]
public static float bottomY = -20f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (transform.position.y < bottomY) {
Destroy(this.gameObject);
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
// Get a reference to the ApplePicker component of Main Camera
ApplePicker apScript = Camera.main.GetComponent<ApplePicker>();
// Call the public AppleDestroyed() method of apScript
apScript.AppleDestroyed();
}
}
}