When I'm trying to destroy an object when its clicked I simply use on mouse down destroy game object but When I port to iphone that 1. doesn't work cause of mouse commands but then 2. I fix it to use touch and instead of when I click the object it destroys it, it actually will simply destroy the object no matter where I click (touch).
Here is the code but the desired effect is when I touch that object it destroys itself...
#pragma strict
var objectToKill : GameObject;
function Update(){
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit, 100)) {
}
if (Input.GetMouseButtonDown(0)){
if (hit.collider.name == objectToKill)
{
Destroy(gameObject);
}
}
}
Also, Input.GetMouseButtonDown does convert to iphone fine other scrips I have use it. but in this case I did change it to iPhoneInput.touchCount == 1 which also works.
– anon95787869I must know, did you place this code dirrectly on the target of destruction or on the camera?
– LeathalNinja1986