Created
May 20, 2017 19:35
-
-
Save atakotestudios/7f3a5a94020084b55383bf177c57b234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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