mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-22 15:18:25 -05:00
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System.Collections;
|
|
using UnityAtoms.BaseAtoms;
|
|
using UnityEngine;
|
|
|
|
namespace MAVRIC.GEEKCup
|
|
{
|
|
public class GameLogic : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject ball;
|
|
[SerializeField] private IntVariable scoreVariable;
|
|
[SerializeField] private GameObject OffScreenSpawnPoint;
|
|
|
|
private GameObject spawnPoint;
|
|
private Transform ballStartTransform;
|
|
public void CheckForSpawnPoint()
|
|
{
|
|
ballStartTransform = OffScreenSpawnPoint.transform;
|
|
spawnPoint = GameObject.Find("SpawnPoint");
|
|
}
|
|
public void MoveBallToSpawnPoint()
|
|
{
|
|
if (spawnPoint is null)
|
|
{
|
|
CheckForSpawnPoint();
|
|
}
|
|
StopCoroutine(MoveBall(spawnPoint.transform));
|
|
StartCoroutine(MoveBall(spawnPoint.transform));
|
|
}
|
|
|
|
public void MoveBallOffScreen()
|
|
{
|
|
StopCoroutine(MoveBall(ballStartTransform));
|
|
StartCoroutine(MoveBall(ballStartTransform));
|
|
}
|
|
|
|
private IEnumerator MoveBall(Transform point)
|
|
{
|
|
if (ball.TryGetComponent(out Rigidbody rbBall))
|
|
{
|
|
rbBall.isKinematic = true;
|
|
yield return new WaitForFixedUpdate();
|
|
|
|
rbBall.position = point.position;
|
|
yield return new WaitForFixedUpdate();
|
|
|
|
rbBall.isKinematic = false;
|
|
}
|
|
}
|
|
}
|
|
}
|