i hv imported a Table Lamp in .fbx format…
i wish to hv such that when i click on d switch in d model…the light should switch on/off…
i hv written d script…
bt ths script is applied all over the Table lamp model…
hw do i run ths script…onli whn d user clicks on a “part” of the model(ie The switch)
plzzz help…![]()
I agree with OrangeLightning there lol! Anyways here’s how i would have approached your problem:
-
have a script with a raycast from the camera in the forward direction.
-
Detect when the user presses the button assigned for switching on the light. When this happens, check whether the ray was hitting the switch or not.
-
if the ray did hit the switch, then access the light and invoke a function in a script that is attached to the light. This function checks if the light is on, if it is on then it switches it off and vice versa.
There is plenty of information on this Webste and also the manual to help you with the coding. Try doing it yourself if you have got a basic idea.
I Hope this helps!