- Home /
camera.ScreenpointToRay(Input.GetTouch(0).position problem with unity remote?
hello!
i have a problem with screenpointoray position. when i test it on unity remote and i press on the screen i get some wierd coordinates... here's the code
if (Input.touchCount > 0) {
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hit;
print (Camera.main.ScreenPointToRay(Input.GetTouch(0).position));
if (Physics.Raycast(ray, out hit, 10000.0f)){
if (hit.collider.name == "drum1"){
print ("drum1hit!");
}
}
}
so if i press on the screen the print function of the coordinates give a value like -14, 1.2, -6.0. this is not even in my camera view... it has to be something like -3, 1.2, ect. the camera is orthographic btw, i'm not sure that would make a difference...
can somebody please help me ?
thnx!
Answer by vignesh211 · Nov 05, 2020 at 02:34 PM
@mmikee85 Its the world position of the gameobject that got hit by the ray(the value that you see in the Unity inspector).
Your answer
![](https://koobas.hobune.stream/wayback/20220613172042im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Scripting a Click event in the Unity Editor 1 Answer
Get 2D Collider with 3D Ray 2 Answers
Raycast ScreenPointToRay Problem 1 Answer
Raycast behavies as if its snapping to grid on standalone build 1 Answer
Cinemachine: ScreenPointToRay raycast 2 Answers