So I’m still wrestling with accessing variables and methods between objects. I understand that there are a number of ways to find the object that contains the script you wish to interact with. However I get hung up on looking for the Game object over the component.
For example: I’m attempting to change the “target” field in my SmoothLookAt function attached to the main camera from a trigger. Everything works except getting the reference to the correct camera object…
SmoothLookAt lookAtTarget = Camera.main.GetComponent(typeof(SmoothLookAt)) as SmoothLookAt;
if (lookAtTarget.target = cameraTarget1.transform)
lookAtTarget.SendMessage("SetTarget(cameraTarget2)");
else
lookAtTarget.SendMessage("SetTarget(cameraTarget1)");
Everywhere I look, it seems that this should work. It currently complains about the “type or namespace name `SmoothLookAt’ could not be found.”
As soon as I feel I’ve got a hold on accessing my objects and components, something jumps up to thicken the plot and send me off on a wild goose chase.
Perhaps providing C# examples in the documentation along side the jscript would really be helpful for us noobs… (like MSDN does) Just a thought.