- Home /
Duplicate Question
destroy touch the screen on gameobject in camera
Hi, I have question. I will create android game in unity but it has problem. I am create gameobject (sphere) with random. I want if touch when on gameobject , delete. But I don't. Can I help me. My code is under...
JAVASCRİPT---
pragma strict
public var zaman: float=0;
function Start () {
}
function Update () {
zaman=zaman+1;
if(zaman % 100==0){
var cube = GameObject.CreatePrimitive(PrimitiveType.Sphere); cube.transform.localScale.x=0.1; cube.transform.localScale.y=0.1; cube.transform.localScale.z=0.1;
cube.AddComponent(Rigidbody); cube.rigidbody.drag=11; cube.transform.position = Vector3 (Random.Range(-3.5,3.4), Random.Range(3,7), -2);
skor.score+=1;
} }
You can use RayCast from camera to object and then you can destroy object colliding with it. http://docs.unity3d.com/Documentation/$$anonymous$$anual/Input.html