Skip to content

Instantly share code, notes, and snippets.

@atakotestudios
Created May 20, 2017 19:35
Show Gist options
  • Save atakotestudios/7f3a5a94020084b55383bf177c57b234 to your computer and use it in GitHub Desktop.
Save atakotestudios/7f3a5a94020084b55383bf177c57b234 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class BallReset : MonoBehaviour {
private Transform myTransform;
private Rigidbody myRigidbody;
private Vector3 startPosition;
public float resetYHeight = 0f;
public GameManager gameManager;
// Use this for initialization
void Start () {
myTransform = GetComponent<Transform>();
myRigidbody = GetComponent<Rigidbody>();
startPosition = myTransform.position;
}
void Update()
{
if(myTransform.position.y < resetYHeight)
{
Reset();
}
}
public void Reset()
{
myTransform.position = startPosition;
myRigidbody.velocity = Vector3.zero;
myRigidbody.angularVelocity = Vector3.zero;
if (gameManager != null)
{
gameManager.CountProjectiles();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment