- Home /
Script Doesn't work on an child?
Hello,
I have just been working on a simple script that will disable a script when the mouse goes over a object, and it works. But when I apply this script to a child object, the object with the script that it is trying to disable, it isn't working anymore. Can someone please explain why this is happening and what I might be able to do to work around this issue.
My code is as follows:
void OnMouseOver (){
playerscript.enabled = false;
}
void OnMouseExit (){
playerscript.enabled = true;
}
$$anonymous$$aybe the object that is detecting the mouse over (the one with the collider) is the parent object, and that's the reason that the child object does not respond. If you could add an inspector screenshot of both objects and the hierarchy.
The Highlighted FPSController Has the playerscript attached and the Blocker Has the code above attached.
Does the Blocker object have collider attached to it so that the On$$anonymous$$ouseOver and On$$anonymous$$ouseExit functions are called? Try Debug.Log() to see if the On$$anonymous$$ouseOver and On$$anonymous$$ouseExit are working.
Your answer
