when i make hit Raycast; and write
if(hit.rigidbody){
washit = true;
}
how can i say something like oncollisionExit but with the ray?
make it false?
when i make hit Raycast; and write
if(hit.rigidbody){
washit = true;
}
how can i say something like oncollisionExit but with the ray?
make it false?
Would be helpful if you said what you were trying to make the game do.
But, if you want to check when the mouse goes over you, and then leaves, scrap the raycast. Instead, look at http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html and try OnMouseOver
, OnMouseExit
… from there. That would go on the thing that checks “is the mouse on me?”, “did the mouse just leave me?”
OnMouse*
does a secret raycast, and keeps track of what it was over last frame. The raycast command is a lot more work, for when you need to do trickier stuff.