Destroying object by touch on Android? (JS)

Hey so, let’s say I have got 5 cubes with same script attached and with random positions and i want to destroy them (not every at once) while tap on it. I found on google someone talking about Physic.raycast but I don’t really understand how does that work :confused: It would be awesome if someoce can maybe explain that to me :slight_smile:

Have a look at the scripting reference, it has examples and everything

Basically, your create a ray from you tap’s position, in the same direction the camera is facing. And you’ll detect if the ray hits any colliders. Which simply means you create a ray under your finger.
(For this all your cubes need to have a collider object!).

if he does hit, you can get the RayCastHit data back from the raycast, and access severl types of data from that hit (exact point, object, texture uv,…)