Created
April 7, 2016 04:05
-
-
Save mm-uddin/204c13efcc6409a0a424f38b0672cb74 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 Score : MonoBehaviour { | |
public TextMesh currentScore; | |
public GameObject ballPref; | |
public Transform paddleObj; | |
GameObject ball; | |
int score; | |
void Update () { | |
ball = GameObject.FindGameObjectWithTag ("Ball"); | |
currentScore.text = " " + score; | |
} | |
void OnTriggerEnter (Collider other){ | |
if (other.tag=="Ball") { | |
score += 1; | |
Destroy (ball); | |
(Instantiate (ballPref, new Vector3 (paddleObj.transform.position.x + 2, paddleObj.transform.position.y, 0), Quaternion.identity) as GameObject).transform.parent = paddleObj; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment