3
I’m trying to create a game similar to Fruit ninja, but I know little of game programming, I understand code c#, could tell me a method if I clicked on a gameobject?
3
I’m trying to create a game similar to Fruit ninja, but I know little of game programming, I understand code c#, could tell me a method if I clicked on a gameobject?
3
Add a Collider (any type), nay mark as "Is Trigger", and add this code to your script:
void OnMouseDown()
{
//clicaram em mim
}
It makes a raycast from the camera point in the click direction.
References: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDown.html
0
You should add a Collider to your Gameobject and tag. After adding 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.
}
}
Incomplete answer, not dealing with the click part, and the event that should be used to treat a click is not this...
True. I made a little mistake, the Oncollisionenter is to treat collisions between objects. Thank you for the correction.
Browser other questions tagged unity3d
You are not signed in. Login or sign up in order to post.
Is the game for mobile devices? For desktop?
– Filipe Moraes