I have a mesh object and I’d like to trigger a certain action when I click on it with a mouse. It is not a gui object, but a regular 3d object. What do I have to do?
I wrote this script and attached it to the object I want to be clickable, but the event doesn’t execute:
function OnMouseDown() {
var lid = GameObject.Find("Lid");
lid.hingeJoint.useLimits = false;
}
I have the meshcollider attached. I have also tried ticking “is trigger” as I think this should be set?
btw, I am getting a “Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor’s mesh shapes! Please change mesh geometry or supply a tensor manually!” error. Still this doesn’t affect my problem, but I would still love to know what I am doing wrong.
I may be remembering this wrong, but I think I got this error with an old version of Unity when I tried to import a totally flat 2D object I’d created in Blender. Adding a little depth to the object would probably have fixed it, although I think I ended up removing that model entirely in the end.