Hi
I am trying to get a 2D sprite to disappear when clicked on, I have a 2D rigid body attached to the sprite as well as a 2D box collider but is not working.
This is the script I am trying to use.
using UnityEngine;
using System.Collections;
public class Balloon : MonoBehaviour {
public SpriteRenderer Balloons = null;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void OnCollisionEnter2D(Collision2D coll) {
if (Input.GetMouseButton(0))
Balloons.GetComponent<SpriteRenderer>().enabled = false;
}
}
Thanks in advance
Your code and your words are saying two different things. If you are talking about clicking on a balloon with the mouse, the easiest solution is to have a script on the balloons with an [OnMouseDown()][1] function. [1]: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnMouseDown.html
– robertbu