I'm trying to create a game similar to fruit ninja, but I know little about game programming, I understand c # code, could you tell me a method of clicking on a gameobject?
I'm trying to create a game similar to fruit ninja, but I know little about game programming, I understand c # code, could you tell me a method of clicking on a gameobject?
Add a Collider (any type), do not mark as "Is Trigger", and add that code to your script:
void OnMouseDown()
{
//clicaram em mim
}
It makes a raycast from the point of the camera in the direction of the click.
References: link
You should add a collider in your GameObject and a tag. After adding the collider and tag, in the script linked to your GameObject you can do the following:
function OnCollisionEnter (c : Collision){
if(c.gameObject.tag == "meuObjeto") {
// Faça alguma coisa.
}
}