|
I am trying to make a script enable on mouse over, so that a specific menu will work only if the mouse is on that specific object. When the mouse is not on the object the same button does a different action. Having trouble so I thought I'd come to the community for help Here is the code so far: var rightclickworking : int = 0; function OnMouseOver () { rightclickworking = 1; } function OnMouseExit () { rightclickguiworking = 0; } function Update () { var script1 = GetComponent("RightClick"); } The error I am getting is: "Object reference not set to an instant of object" at line 15 and 18 where I specified. This script is attached to the object and script1 is attached to the camera. Could anybody help me with what I am doing wrong?
(comments are locked)
|
|
Directly calling If you need to access to a component on another object, you must first have a reference to that gameobject and then use Sidenote: Just use booleans for flags instead of Now you can just do: ... or just: Thanks for the help :)
Nov 05 '11 at 10:07 AM
garanon
You're welcome. If your problems are solved consider upvoting and/or accepting answers on your questions.
Nov 05 '11 at 10:18 AM
gfr
I have upvoted as I understand what you're saying but no matter how many times I go over your code I can't make sense of what I must do to get it working for myself. I don't understand why you use "var script1 : RightClick" which is affecting the rest of the code I will get some sleep and hopefully make sense of it tomorrow but I've literally been reading it over and over for an hour trying my own variations with no result
Nov 05 '11 at 01:47 PM
garanon
Nov 05 '11 at 02:23 PM
gfr
Well thanks for the help but I'm still confused :P due to me being a newbie I assume, my tutor just threw me into the deep end so I have little knowledge of the things I am or aren't achieving. I'll mark it as right though in case anybody else wants to have a look but I guess not for me :P
Nov 05 '11 at 03:14 PM
garanon
(comments are locked)
|
