- Home /
Question by
yashesh · May 29, 2013 at 12:47 PM ·
cameragameobjectraycastguitextureraycasthit
Some GameObjects can't touch !!!
Hello everyone, I am developing game for iPhone and Android and i have different GameObjects and GUITexture and i have write code for touch event for all objects and everything was working perfectly. But after change my Main Camera angle some of the objects and GUITexture' which are in the corner of the screen that objects and GUITexture's touch method not calling. I found that if i am putting that object into middle to Screen then it's touch event working properly.
For touch i have used bellow code:
ray = Camera.main.ScreenPointToRay(Input.mousePosition); //I can't get touch.position to work
if(Input.GetMouseButtonUp(0)){
if(Physics.Raycast(ray,hit,1000)){
if(hit.collider.gameObject.name == "Sound"){
can anybody help me ?
Thanks in advance.
Comment
Im using this on the camera dont know if that helps at all.
var hit : RaycastHit;
if (Physics.Raycast(transform.position, transform.forward, hit , 3)){
function On$$anonymous$$ouseDown (){
if (Input.GetButtonDown("Fire1") && collider.gameObject.tag == "my tag"){
Debug.Log("hello");
}
}
}
problem is that not all the object hit by touch or mouse click if i placed it in middle of the screen the it's working ..