- Home /
Falling object touch
Hi, I have some cubes falling from the top to the bottom of the screen with gravity, and they must disappear when touched. As cubes fall faster it happens lots of times that the finger touch on them is not detected.
here's the part of the code which manage that part:
foreach (Touch t in Input.touches) {
if (t.phase != TouchPhase.Moved && t.phase != TouchPhase.Stationary) {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay (t.position);
if (Physics.Raycast (ray, out hit, 100f)) {
if (hit.collider.gameObject.tag == "cube") {
// score update and object destroyed
Any help is really appreciated, thanks.
Comment