I just need to know how to bung in an else if (Input.GetMouseButtonDown(0)) then dont do anything after start but it the debugger just bullies me.
using UnityEngine;
using System.Collections;
public class Ball : MonoBehaviour {
public Paddle paddle;
private bool hasStarted = false;
private Vector3 paddleToBallVector;
// Use this for initialization
void Start () {
paddleToBallVector = this.transform.position - paddle.transform.position;
}
// Update is called once per frame
void Update () {
if (!hasStarted) {
// Lock the ball relative to the paddle.
this.transform.position = paddle.transform.position + paddleToBallVector;
}
// Wait for a mouse press to launch.
if (Input.GetMouseButtonDown(0)) {
print ("Mouse clicked, launch ball");
hasStarted = true;
this.rigidbody2D.velocity = new Vector2 (2f, 10f);
}
}
void OnCollisionEnter2D (Collision2D collision) {
if (hasStarted)
audio.Play();
}
}